CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js93682 linesDownload Raw Back to lib
1/**2 * MIT License3 *4 * Copyright (c) 2022 Lark Technologies Pte. Ltd.5 *6 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:7 *8 * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.9 *10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.11 */12 13'use strict';14 15Object.defineProperty(exports, '__esModule', { value: true });16 17var axios = require('axios');18var fs = require('fs');19var path = require('path');20var crypto = require('crypto');21var qs = require('qs');22var identity = require('lodash.identity');23var pickBy = require('lodash.pickby');24var merge = require('lodash.merge');25var qs$1 = require('querystring');26var WebSocket = require('ws');27var http = require('http');28var https = require('https');29var dns = require('dns');30var net = require('net');31 32function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }33 34var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);35var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);36var path__default = /*#__PURE__*/_interopDefaultLegacy(path);37var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);38var identity__default = /*#__PURE__*/_interopDefaultLegacy(identity);39var pickBy__default = /*#__PURE__*/_interopDefaultLegacy(pickBy);40var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);41var qs__default = /*#__PURE__*/_interopDefaultLegacy(qs$1);42var WebSocket__default = /*#__PURE__*/_interopDefaultLegacy(WebSocket);43var http__default = /*#__PURE__*/_interopDefaultLegacy(http);44var https__default = /*#__PURE__*/_interopDefaultLegacy(https);45 46/******************************************************************************
47Copyright (c) Microsoft Corporation.
48
49Permission to use, copy, modify, and/or distribute this software for any
50purpose with or without fee is hereby granted.
51
52THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
53REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
54AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
55INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
56LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
57OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
58PERFORMANCE OF THIS SOFTWARE.
59***************************************************************************** */
60
61function __rest(s, e) {
62    var t = {};
63    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
64        t[p] = s[p];
65    if (s != null && typeof Object.getOwnPropertySymbols === "function")
66        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
67            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
68                t[p[i]] = s[p[i]];
69        }
70    return t;
71}
72
73function __awaiter(thisArg, _arguments, P, generator) {
74    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
75    return new (P || (P = Promise))(function (resolve, reject) {
76        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
77        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
78        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
79        step((generator = generator.apply(thisArg, _arguments || [])).next());
80    });
81}
82
83function __values(o) {
84    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
85    if (m) return m.call(o);
86    if (o && typeof o.length === "number") return {
87        next: function () {
88            if (o && i >= o.length) o = void 0;
89            return { value: o && o[i++], done: !o };
90        }
91    };
92    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
93}
94
95function __await(v) {
96    return this instanceof __await ? (this.v = v, this) : new __await(v);
97}
98
99function __asyncGenerator(thisArg, _arguments, generator) {
100    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
101    var g = generator.apply(thisArg, _arguments || []), i, q = [];
102    return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
103    function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
104    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
105    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
106    function fulfill(value) { resume("next", value); }
107    function reject(value) { resume("throw", value); }
108    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
109}
110
111function __asyncValues(o) {
112    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
113    var m = o[Symbol.asyncIterator], i;
114    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
115    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
116    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
117}
118
119typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
120    var e = new Error(message);
121    return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
122};123 124/**125 * Resolve the SDK's own version from `package.json`. The source lives at126 * `utils/user-agent.ts`; the published bundle lives at `lib/index.js` or127 * `es/index.js`. In both shapes the package.json sits exactly one level128 * above the code, so `__dirname/..` is the primary candidate. A second129 * candidate (two levels up) covers downstream bundlers that re-emit this130 * module at a deeper path.131 *132 * We sanity-check `name === '@larksuiteoapi/node-sdk'` so we don't133 * accidentally read an unrelated package.json that happens to sit in a134 * parent directory during local development.135 */136let cachedVersion;137function getSdkVersion() {138    if (cachedVersion !== undefined)139        return cachedVersion;140    const candidates = [141        path__default["default"].resolve(__dirname, '..', 'package.json'),142        path__default["default"].resolve(__dirname, '..', '..', 'package.json'),143    ];144    for (const p of candidates) {145        try {146            const pkg = JSON.parse(fs__default["default"].readFileSync(p, 'utf-8'));147            if (pkg.name === '@larksuiteoapi/node-sdk' && typeof pkg.version === 'string') {148                cachedVersion = pkg.version;149                return pkg.version;150            }151        }152        catch (_a) {153            // try next candidate154        }155    }156    cachedVersion = 'unknown';157    return 'unknown';158}159/**160 * Sanitize a caller-supplied `source` tag so it can be safely concatenated161 * into a User-Agent header. Non-token characters are replaced with '_'162 * and the result is clamped to 64 characters. Never throws.163 */164function sanitizeSource(raw) {165    return raw.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 64);166}167function buildUserAgent(source, opts) {168    let ua = `oapi-node-sdk/${getSdkVersion()}`;169    if (source) {170        const clean = sanitizeSource(source);171        if (clean)172            ua += ` source/${clean}`;173    }174    if (opts === null || opts === void 0 ? void 0 : opts.extraTags) {175        for (const t of opts.extraTags) {176            const clean = sanitizeSource(t);177            if (clean)178                ua += ` ${clean}`;179        }180    }181    return ua;182}183 184const defaultHttpInstance = axios__default["default"].create();185// Fallback UA for callers that bypass Client/WSClient and hit186// `defaultHttpInstance` directly. Client.formatPayload overrides this with187// a source-enriched UA when a `source` option is configured.188const FALLBACK_UA = buildUserAgent();189defaultHttpInstance.interceptors.request.use((req) => {190    if (req.headers && !req.headers['User-Agent']) {191        req.headers['User-Agent'] = FALLBACK_UA;192    }193    return req;194}, undefined, { synchronous: true });195defaultHttpInstance.interceptors.response.use((resp) => {196    if (resp.config['$return_headers']) {197        return {198            data: resp.data,199            headers: resp.headers200        };201    }202    return resp.data;203});204 205exports.AppType = void 0;206(function (AppType) {207    AppType[AppType["SelfBuild"] = 0] = "SelfBuild";208    AppType[AppType["ISV"] = 1] = "ISV";209})(exports.AppType || (exports.AppType = {}));210exports.Domain = void 0;211(function (Domain) {212    Domain[Domain["Feishu"] = 0] = "Feishu";213    Domain[Domain["Lark"] = 1] = "Lark";214})(exports.Domain || (exports.Domain = {}));215exports.LoggerLevel = void 0;216(function (LoggerLevel) {217    LoggerLevel[LoggerLevel["fatal"] = 0] = "fatal";218    LoggerLevel[LoggerLevel["error"] = 1] = "error";219    LoggerLevel[LoggerLevel["warn"] = 2] = "warn";220    LoggerLevel[LoggerLevel["info"] = 3] = "info";221    LoggerLevel[LoggerLevel["debug"] = 4] = "debug";222    LoggerLevel[LoggerLevel["trace"] = 5] = "trace";223})(exports.LoggerLevel || (exports.LoggerLevel = {}));224 225const CEventType = Symbol('event-type');226const CTenantKey = Symbol('tenant-key');227const CAppTicket = Symbol('app-ticket');228const CTenantAccessToken = Symbol('tenant-access-token');229const CWithHelpdeskAuthorization = Symbol('with-helpdesk-authorization');230const CWithUserAccessToken = Symbol('with-user-access-token');231const CUserAccessToken = Symbol('user-access-token');232const CAilySessionRecord = Symbol('aily-session-record');233 234const string2Base64 = (content) => Buffer.from(content).toString('base64');235 236class DefaultCache {237    constructor() {238        this.values = new Map();239    }240    // When there is a namespace, splice the namespace and key to form a new key241    getCacheKey(key, namespace) {242        if (namespace) {243            return `${namespace}/${key.toString()}`;244        }245        return key;246    }247    get(key, options) {248        return __awaiter(this, void 0, void 0, function* () {249            const cacheKey = this.getCacheKey(key, options === null || options === void 0 ? void 0 : options.namespace);250            const data = this.values.get(cacheKey);251            if (data) {252                const { value, expiredTime } = data;253                if (!expiredTime || expiredTime - new Date().getTime() > 0) {254                    return value;255                }256            }257            return undefined;258        });259    }260    set(key, value, expiredTime, options) {261        return __awaiter(this, void 0, void 0, function* () {262            const cacheKey = this.getCacheKey(key, options === null || options === void 0 ? void 0 : options.namespace);263            this.values.set(cacheKey, {264                value,265                expiredTime,266            });267            return true;268        });269    }270}271const internalCache = new DefaultCache();272 273class AESCipher {274    constructor(key) {275        const hash = crypto__default["default"].createHash('sha256');276        hash.update(key);277        this.key = hash.digest();278    }279    decrypt(encrypt) {280        const encryptBuffer = Buffer.from(encrypt, 'base64');281        const decipher = crypto__default["default"].createDecipheriv('aes-256-cbc', this.key, encryptBuffer.slice(0, 16));282        let decrypted = decipher.update(encryptBuffer.slice(16).toString('hex'), 'hex', 'utf8');283        decrypted += decipher.final('utf8');284        return decrypted;285    }286}287 288const formatDomain = (domain) => {289    switch (domain) {290        case exports.Domain.Feishu:291            return 'https://open.feishu.cn';292        case exports.Domain.Lark:293            return 'https://open.larksuite.com';294        default:295            return domain;296    }297};298 299const fillApiPath = (apiPath, pathSupplement = {}) => apiPath.replace(/:([^/]+)/g, (_, $1) => {300    if (pathSupplement[$1] !== undefined) {301        return pathSupplement[$1];302    }303    throw new Error(`request miss ${$1} path argument`);304});305 306const assert = (predication, callback) => __awaiter(void 0, void 0, void 0, function* () {307    const isInvoke = typeof predication === 'function' ? predication() : predication;308    if (isInvoke) {309        yield callback();310    }311});312 313const formatUrl = (url) => (url ? url.replace(/^\//, '') : '');314 315const pick = (obj, keys = []) => {316    const result = {};317    if (!obj) {318        return result;319    }320    keys.forEach(key => {321        if (Object.prototype.hasOwnProperty.call(obj, key)) {322            result[key] = obj[key];323        }324    });325    return result;326};327 328const formatErrors = (e) => {329    var _a;330    if (e instanceof axios.AxiosError) {331        const { message, response, request, config } = pick(e, [332            'message',333            'response',334            'request',335            'config',336        ]);337        const filteredErrorInfo = {338            message,339            config: pick(config, ['data', 'url', 'params', 'method']),340            request: pick(request, ['protocol', 'host', 'path', 'method']),341            response: pick(response, ['data', 'status', 'statusText']),342        };343        const errors = [filteredErrorInfo];344        const specificError = (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data;345        if (specificError) {346            errors.push(Object.assign(Object.assign({}, specificError), (specificError.error ? specificError.error : {})));347        }348        return errors;349    }350    return [e];351};352 353// auto gen354class Client$16 {355    constructor() {356        /**357         * 智能门禁358         */359        this.acs = {360            /**361             * access_record.access_photo362             */363            accessRecordAccessPhoto: {364                /**365                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=access_record.access_photo&apiName=get&version=v1 click to debug }366                 *367                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/access_record-access_photo/get document }368                 *369                 * 下载开门时的人脸识别图片370                 *371                 * 用户在门禁考勤机上成功开门或打卡后,智能门禁应用都会生成一条门禁记录,对于使用人脸识别方式进行开门的识别记录,还会有抓拍图。;;可以用该接口下载开门时的人脸识别照片。372                 */373                get: (payload, options) => __awaiter(this, void 0, void 0, function* () {374                    const { headers, params, data, path } = yield this.formatPayload(payload, options);375                    const res = yield this.httpInstance376                        .request({377                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records/:access_record_id/access_photo`, path),378                        method: "GET",379                        headers,380                        data,381                        params,382                        responseType: "stream",383                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),384                        $return_headers: true,385                    })386                        .catch((e) => {387                        this.logger.error(formatErrors(e));388                        throw e;389                    });390                    const checkIsReadable = () => {391                        const consumedError = "The stream has already been consumed";392                        if (!res.data.readable) {393                            this.logger.error(consumedError);394                            throw new Error(consumedError);395                        }396                    };397                    return {398                        writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {399                            checkIsReadable();400                            return new Promise((resolve, reject) => {401                                const writableStream = fs__default["default"].createWriteStream(filePath);402                                writableStream.on("finish", () => {403                                    resolve(filePath);404                                });405                                writableStream.on("error", (e) => {406                                    reject(e);407                                });408                                res.data.pipe(writableStream);409                            });410                        }),411                        getReadableStream: () => {412                            checkIsReadable();413                            return res.data;414                        },415                        headers: res.headers,416                    };417                }),418            },419            /**420             * 门禁记录421             */422            accessRecord: {423                listWithIterator: (payload, options) => __awaiter(this, void 0, void 0, function* () {424                    const { headers, params, data, path } = yield this.formatPayload(payload, options);425                    const sendRequest = (innerPayload) => __awaiter(this, void 0, void 0, function* () {426                        const res = yield this.httpInstance427                            .request({428                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records`, path),429                            method: "GET",430                            headers: pickBy__default["default"](innerPayload.headers, identity__default["default"]),431                            params: pickBy__default["default"](innerPayload.params, identity__default["default"]),432                            data,433                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),434                        })435                            .catch((e) => {436                            this.logger.error(formatErrors(e));437                        });438                        return res;439                    });440                    const Iterable = {441                        [Symbol.asyncIterator]() {442                            return __asyncGenerator(this, arguments, function* _a() {443                                let hasMore = true;444                                let pageToken;445                                while (hasMore) {446                                    try {447                                        const res = yield __await(sendRequest({448                                            headers,449                                            params: Object.assign(Object.assign({}, params), { page_token: pageToken }),450                                            data,451                                        }));452                                        const _b = (res === null || res === void 0 ? void 0 : res.data) || {}, { 453                                        // @ts-ignore454                                        has_more, 455                                        // @ts-ignore456                                        page_token, 457                                        // @ts-ignore458                                        next_page_token } = _b, rest = __rest(_b, ["has_more", "page_token", "next_page_token"]);459                                        yield yield __await(rest);460                                        hasMore = Boolean(has_more);461                                        pageToken = page_token || next_page_token;462                                    }463                                    catch (e) {464                                        yield yield __await(null);465                                        break;466                                    }467                                }468                            });469                        },470                    };471                    return Iterable;472                }),473                /**474                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=access_record&apiName=list&version=v1 click to debug }475                 *476                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/access_record/list document }477                 *478                 * 获取门禁记录列表479                 *480                 * 用户在门禁考勤机上成功开门或打卡后,智能门禁应用都会生成一条门禁记录。;;该接口返回满足查询参数的识别记录。481                 */482                list: (payload, options) => __awaiter(this, void 0, void 0, function* () {483                    const { headers, params, data, path } = yield this.formatPayload(payload, options);484                    return this.httpInstance485                        .request({486                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records`, path),487                        method: "GET",488                        data,489                        params,490                        headers,491                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),492                    })493                        .catch((e) => {494                        this.logger.error(formatErrors(e));495                        throw e;496                    });497                }),498            },499            /**500             * 门禁设备501             */502            device: {503                /**504                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=device&apiName=list&version=v1 click to debug }505                 *506                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/device/list document }507                 *508                 * 获取门禁设备列表509                 *510                 * 使用该接口获取租户内所有门禁设备。511                 */512                list: (payload, options) => __awaiter(this, void 0, void 0, function* () {513                    const { headers, params, data, path } = yield this.formatPayload(payload, options);514                    return this.httpInstance515                        .request({516                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/devices`, path),517                        method: "GET",518                        data,519                        params,520                        headers,521                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),522                    })523                        .catch((e) => {524                        this.logger.error(formatErrors(e));525                        throw e;526                    });527                }),528            },529            /**530             * rule_external531             */532            ruleExternal: {533                /**534                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=create&version=v1 click to debug }535                 *536                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=acs&resource=rule_external&version=v1 document }537                 */538                create: (payload, options) => __awaiter(this, void 0, void 0, function* () {539                    const { headers, params, data, path } = yield this.formatPayload(payload, options);540                    return this.httpInstance541                        .request({542                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),543                        method: "POST",544                        data,545                        params,546                        headers,547                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),548                    })549                        .catch((e) => {550                        this.logger.error(formatErrors(e));551                        throw e;552                    });553                }),554                /**555                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=delete&version=v1 click to debug }556                 *557                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=delete&project=acs&resource=rule_external&version=v1 document }558                 */559                delete: (payload, options) => __awaiter(this, void 0, void 0, function* () {560                    const { headers, params, data, path } = yield this.formatPayload(payload, options);561                    return this.httpInstance562                        .request({563                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),564                        method: "DELETE",565                        data,566                        params,567                        headers,568                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),569                    })570                        .catch((e) => {571                        this.logger.error(formatErrors(e));572                        throw e;573                    });574                }),575                /**576                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=device_bind&version=v1 click to debug }577                 *578                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=device_bind&project=acs&resource=rule_external&version=v1 document }579                 */580                deviceBind: (payload, options) => __awaiter(this, void 0, void 0, function* () {581                    const { headers, params, data, path } = yield this.formatPayload(payload, options);582                    return this.httpInstance583                        .request({584                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external/device_bind`, path),585                        method: "POST",586                        data,587                        params,588                        headers,589                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),590                    })591                        .catch((e) => {592                        this.logger.error(formatErrors(e));593                        throw e;594                    });595                }),596                /**597                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=get&version=v1 click to debug }598                 *599                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=acs&resource=rule_external&version=v1 document }600                 */601                get: (payload, options) => __awaiter(this, void 0, void 0, function* () {602                    const { headers, params, data, path } = yield this.formatPayload(payload, options);603                    return this.httpInstance604                        .request({605                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),606                        method: "GET",607                        data,608                        params,609                        headers,610                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),611                    })612                        .catch((e) => {613                        this.logger.error(formatErrors(e));614                        throw e;615                    });616                }),617            },618            /**619             * user.face620             */621            userFace: {622                /**623                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user.face&apiName=get&version=v1 click to debug }624                 *625                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user-face/get document }626                 *627                 * 下载人脸图片628                 *629                 * 对于已经录入人脸图片的用户,可以使用该接口下载用户人脸图片。630                 */631                get: (payload, options) => __awaiter(this, void 0, void 0, function* () {632                    const { headers, params, data, path } = yield this.formatPayload(payload, options);633                    const res = yield this.httpInstance634                        .request({635                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/users/:user_id/face`, path),636                        method: "GET",637                        headers,638                        data,639                        params,640                        responseType: "stream",641                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),642                        $return_headers: true,643                    })644                        .catch((e) => {645                        this.logger.error(formatErrors(e));646                        throw e;647                    });648                    const checkIsReadable = () => {649                        const consumedError = "The stream has already been consumed";650                        if (!res.data.readable) {651                            this.logger.error(consumedError);652                            throw new Error(consumedError);653                        }654                    };655                    return {656                        writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {657                            checkIsReadable();658                            return new Promise((resolve, reject) => {659                                const writableStream = fs__default["default"].createWriteStream(filePath);660                                writableStream.on("finish", () => {661                                    resolve(filePath);662                                });663                                writableStream.on("error", (e) => {664                                    reject(e);665                                });666                                res.data.pipe(writableStream);667                            });668                        }),669                        getReadableStream: () => {670                            checkIsReadable();671                            return res.data;672                        },673                        headers: res.headers,674                    };675                }),676                /**677                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user.face&apiName=update&version=v1 click to debug }678                 *679                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user-face/update document }680                 *681                 * 上传人脸图片682                 *683                 * 用户需要录入人脸图片才可以使用门禁考勤机。使用该 API 上传门禁用户的人脸图片。684                 */685                update: (payload, options) => __awaiter(this, void 0, void 0, function* () {686                    const { headers, params, data, path } = yield this.formatPayload(payload, options);687                    const res = yield this.httpInstance688                        .request({689                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/users/:user_id/face`, path),690                        method: "PUT",691                        data,692                        params,693                        headers: Object.assign(Object.assign({}, headers), { "Content-Type": "multipart/form-data" }),694                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),695                    })696                        .catch((e) => {697                        this.logger.error(formatErrors(e));698                        throw e;699                    });700                    return (res === null || res === void 0 ? void 0 : res.data) || null;701                }),702            },703            /**704             * 用户管理705             */706            user: {707                /**708                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user&apiName=get&version=v1 click to debug }709                 *710                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user/get document }711                 *712                 * 获取单个用户信息713                 *714                 * 该接口用于获取智能门禁中单个用户的信息。715                 *716                 * 只能获取已加入智能门禁权限组的用户717                 */718                get: (payload, options) => __awaiter(this, void 0, void 0, function* () {719                    const { headers, params, data, path } = yield this.formatPayload(payload, options);720                    return this.httpInstance721                        .request({722                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/users/:user_id`, path),723                        method: "GET",724                        data,725                        params,726                        headers,727                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),728                    })729                        .catch((e) => {730                        this.logger.error(formatErrors(e));731                        throw e;732                    });733                }),734                listWithIterator: (payload, options) => __awaiter(this, void 0, void 0, function* () {735                    const { headers, params, data, path } = yield this.formatPayload(payload, options);736                    const sendRequest = (innerPayload) => __awaiter(this, void 0, void 0, function* () {737                        const res = yield this.httpInstance738                            .request({739                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/users`, path),740                            method: "GET",741                            headers: pickBy__default["default"](innerPayload.headers, identity__default["default"]),742                            params: pickBy__default["default"](innerPayload.params, identity__default["default"]),743                            data,744                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),745                        })746                            .catch((e) => {747                            this.logger.error(formatErrors(e));748                        });749                        return res;750                    });751                    const Iterable = {752                        [Symbol.asyncIterator]() {753                            return __asyncGenerator(this, arguments, function* _a() {754                                let hasMore = true;755                                let pageToken;756                                while (hasMore) {757                                    try {758                                        const res = yield __await(sendRequest({759                                            headers,760                                            params: Object.assign(Object.assign({}, params), { page_token: pageToken }),761                                            data,762                                        }));763                                        const _b = (res === null || res === void 0 ? void 0 : res.data) || {}, { 764                                        // @ts-ignore765                                        has_more, 766                                        // @ts-ignore767                                        page_token, 768                                        // @ts-ignore769                                        next_page_token } = _b, rest = __rest(_b, ["has_more", "page_token", "next_page_token"]);770                                        yield yield __await(rest);771                                        hasMore = Boolean(has_more);772                                        pageToken = page_token || next_page_token;773                                    }774                                    catch (e) {775                                        yield yield __await(null);776                                        break;777                                    }778                                }779                            });780                        },781                    };782                    return Iterable;783                }),784                /**785                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user&apiName=list&version=v1 click to debug }786                 *787                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user/list document }788                 *789                 * 获取用户列表790                 *791                 * 使用该接口获取智能门禁中所有用户信息。792                 *793                 * 只能获取已加入智能门禁权限组的用户。794                 */795                list: (payload, options) => __awaiter(this, void 0, void 0, function* () {796                    const { headers, params, data, path } = yield this.formatPayload(payload, options);797                    return this.httpInstance798                        .request({799                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/users`, path),800                        method: "GET",801                        data,802                        params,803                        headers,804                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),805                    })806                        .catch((e) => {807                        this.logger.error(formatErrors(e));808                        throw e;809                    });810                }),811                /**812                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user&apiName=patch&version=v1 click to debug }813                 *814                 * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user/patch document }815                 *816                 * 修改用户部分信息817                 *818                 * 飞书智能门禁在人脸识别成功后会有韦根信号输出,输出用户的卡号。;对于使用韦根协议的门禁系统,企业可使用该接口录入用户卡号。819                 */820                patch: (payload, options) => __awaiter(this, void 0, void 0, function* () {821                    const { headers, params, data, path } = yield this.formatPayload(payload, options);822                    return this.httpInstance823                        .request({824                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/users/:user_id`, path),825                        method: "PATCH",826                        data,827                        params,828                        headers,829                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),830                    })831                        .catch((e) => {832                        this.logger.error(formatErrors(e));833                        throw e;834                    });835                }),836            },837            /**838             * visitor839             */840            visitor: {841                /**842                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=visitor&apiName=create&version=v1 click to debug }843                 *844                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=acs&resource=visitor&version=v1 document }845                 */846                create: (payload, options) => __awaiter(this, void 0, void 0, function* () {847                    const { headers, params, data, path } = yield this.formatPayload(payload, options);848                    return this.httpInstance849                        .request({850                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/visitors`, path),851                        method: "POST",852                        data,853                        params,854                        headers,855                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),856                    })857                        .catch((e) => {858                        this.logger.error(formatErrors(e));859                        throw e;860                    });861                }),862                /**863                 * {@link https://open.feishu.cn/api-explorer?project=acs&resource=visitor&apiName=delete&version=v1 click to debug }864                 *865                 * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=delete&project=acs&resource=visitor&version=v1 document }866                 */867                delete: (payload, options) => __awaiter(this, void 0, void 0, function* () {868                    const { headers, params, data, path } = yield this.formatPayload(payload, options);869                    return this.httpInstance870                        .request({871                        url: fillApiPath(`${this.domain}/open-apis/acs/v1/visitors/:visitor_id`, path),872                        method: "DELETE",873                        data,874                        params,875                        headers,876                        paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),877                    })878                        .catch((e) => {879                        this.logger.error(formatErrors(e));880                        throw e;881                    });882                }),883            },884            v1: {885                /**886                 * access_record.access_photo887                 */888                accessRecordAccessPhoto: {889                    /**890                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=access_record.access_photo&apiName=get&version=v1 click to debug }891                     *892                     * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/access_record-access_photo/get document }893                     *894                     * 下载开门时的人脸识别图片895                     *896                     * 用户在门禁考勤机上成功开门或打卡后,智能门禁应用都会生成一条门禁记录,对于使用人脸识别方式进行开门的识别记录,还会有抓拍图。;;可以用该接口下载开门时的人脸识别照片。897                     */898                    get: (payload, options) => __awaiter(this, void 0, void 0, function* () {899                        const { headers, params, data, path } = yield this.formatPayload(payload, options);900                        const res = yield this.httpInstance901                            .request({902                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records/:access_record_id/access_photo`, path),903                            method: "GET",904                            headers,905                            data,906                            params,907                            responseType: "stream",908                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),909                            $return_headers: true,910                        })911                            .catch((e) => {912                            this.logger.error(formatErrors(e));913                            throw e;914                        });915                        const checkIsReadable = () => {916                            const consumedError = "The stream has already been consumed";917                            if (!res.data.readable) {918                                this.logger.error(consumedError);919                                throw new Error(consumedError);920                            }921                        };922                        return {923                            writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {924                                checkIsReadable();925                                return new Promise((resolve, reject) => {926                                    const writableStream = fs__default["default"].createWriteStream(filePath);927                                    writableStream.on("finish", () => {928                                        resolve(filePath);929                                    });930                                    writableStream.on("error", (e) => {931                                        reject(e);932                                    });933                                    res.data.pipe(writableStream);934                                });935                            }),936                            getReadableStream: () => {937                                checkIsReadable();938                                return res.data;939                            },940                            headers: res.headers,941                        };942                    }),943                },944                /**945                 * 门禁记录946                 */947                accessRecord: {948                    listWithIterator: (payload, options) => __awaiter(this, void 0, void 0, function* () {949                        const { headers, params, data, path } = yield this.formatPayload(payload, options);950                        const sendRequest = (innerPayload) => __awaiter(this, void 0, void 0, function* () {951                            const res = yield this.httpInstance952                                .request({953                                url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records`, path),954                                method: "GET",955                                headers: pickBy__default["default"](innerPayload.headers, identity__default["default"]),956                                params: pickBy__default["default"](innerPayload.params, identity__default["default"]),957                                data,958                                paramsSerializer: (params) => qs.stringify(params, {959                                    arrayFormat: "repeat",960                                }),961                            })962                                .catch((e) => {963                                this.logger.error(formatErrors(e));964                            });965                            return res;966                        });967                        const Iterable = {968                            [Symbol.asyncIterator]() {969                                return __asyncGenerator(this, arguments, function* _a() {970                                    let hasMore = true;971                                    let pageToken;972                                    while (hasMore) {973                                        try {974                                            const res = yield __await(sendRequest({975                                                headers,976                                                params: Object.assign(Object.assign({}, params), { page_token: pageToken }),977                                                data,978                                            }));979                                            const _b = (res === null || res === void 0 ? void 0 : res.data) || {}, { 980                                            // @ts-ignore981                                            has_more, 982                                            // @ts-ignore983                                            page_token, 984                                            // @ts-ignore985                                            next_page_token } = _b, rest = __rest(_b, ["has_more", "page_token", "next_page_token"]);986                                            yield yield __await(rest);987                                            hasMore = Boolean(has_more);988                                            pageToken = page_token || next_page_token;989                                        }990                                        catch (e) {991                                            yield yield __await(null);992                                            break;993                                        }994                                    }995                                });996                            },997                        };998                        return Iterable;999                    }),1000                    /**1001                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=access_record&apiName=list&version=v1 click to debug }1002                     *1003                     * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/access_record/list document }1004                     *1005                     * 获取门禁记录列表1006                     *1007                     * 用户在门禁考勤机上成功开门或打卡后,智能门禁应用都会生成一条门禁记录。;;该接口返回满足查询参数的识别记录。1008                     */1009                    list: (payload, options) => __awaiter(this, void 0, void 0, function* () {1010                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1011                        return this.httpInstance1012                            .request({1013                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/access_records`, path),1014                            method: "GET",1015                            data,1016                            params,1017                            headers,1018                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1019                        })1020                            .catch((e) => {1021                            this.logger.error(formatErrors(e));1022                            throw e;1023                        });1024                    }),1025                },1026                /**1027                 * 门禁设备1028                 */1029                device: {1030                    /**1031                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=device&apiName=list&version=v1 click to debug }1032                     *1033                     * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/device/list document }1034                     *1035                     * 获取门禁设备列表1036                     *1037                     * 使用该接口获取租户内所有门禁设备。1038                     */1039                    list: (payload, options) => __awaiter(this, void 0, void 0, function* () {1040                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1041                        return this.httpInstance1042                            .request({1043                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/devices`, path),1044                            method: "GET",1045                            data,1046                            params,1047                            headers,1048                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1049                        })1050                            .catch((e) => {1051                            this.logger.error(formatErrors(e));1052                            throw e;1053                        });1054                    }),1055                },1056                /**1057                 * rule_external1058                 */1059                ruleExternal: {1060                    /**1061                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=create&version=v1 click to debug }1062                     *1063                     * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=acs&resource=rule_external&version=v1 document }1064                     */1065                    create: (payload, options) => __awaiter(this, void 0, void 0, function* () {1066                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1067                        return this.httpInstance1068                            .request({1069                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),1070                            method: "POST",1071                            data,1072                            params,1073                            headers,1074                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1075                        })1076                            .catch((e) => {1077                            this.logger.error(formatErrors(e));1078                            throw e;1079                        });1080                    }),1081                    /**1082                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=delete&version=v1 click to debug }1083                     *1084                     * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=delete&project=acs&resource=rule_external&version=v1 document }1085                     */1086                    delete: (payload, options) => __awaiter(this, void 0, void 0, function* () {1087                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1088                        return this.httpInstance1089                            .request({1090                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),1091                            method: "DELETE",1092                            data,1093                            params,1094                            headers,1095                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1096                        })1097                            .catch((e) => {1098                            this.logger.error(formatErrors(e));1099                            throw e;1100                        });1101                    }),1102                    /**1103                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=device_bind&version=v1 click to debug }1104                     *1105                     * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=device_bind&project=acs&resource=rule_external&version=v1 document }1106                     */1107                    deviceBind: (payload, options) => __awaiter(this, void 0, void 0, function* () {1108                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1109                        return this.httpInstance1110                            .request({1111                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external/device_bind`, path),1112                            method: "POST",1113                            data,1114                            params,1115                            headers,1116                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1117                        })1118                            .catch((e) => {1119                            this.logger.error(formatErrors(e));1120                            throw e;1121                        });1122                    }),1123                    /**1124                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=rule_external&apiName=get&version=v1 click to debug }1125                     *1126                     * {@link https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=acs&resource=rule_external&version=v1 document }1127                     */1128                    get: (payload, options) => __awaiter(this, void 0, void 0, function* () {1129                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1130                        return this.httpInstance1131                            .request({1132                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/rule_external`, path),1133                            method: "GET",1134                            data,1135                            params,1136                            headers,1137                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1138                        })1139                            .catch((e) => {1140                            this.logger.error(formatErrors(e));1141                            throw e;1142                        });1143                    }),1144                },1145                /**1146                 * user.face1147                 */1148                userFace: {1149                    /**1150                     * {@link https://open.feishu.cn/api-explorer?project=acs&resource=user.face&apiName=get&version=v1 click to debug }1151                     *1152                     * {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user-face/get document }1153                     *1154                     * 下载人脸图片1155                     *1156                     * 对于已经录入人脸图片的用户,可以使用该接口下载用户人脸图片。1157                     */1158                    get: (payload, options) => __awaiter(this, void 0, void 0, function* () {1159                        const { headers, params, data, path } = yield this.formatPayload(payload, options);1160                        const res = yield this.httpInstance1161                            .request({1162                            url: fillApiPath(`${this.domain}/open-apis/acs/v1/users/:user_id/face`, path),1163                            method: "GET",1164                            headers,1165                            data,1166                            params,1167                            responseType: "stream",1168                            paramsSerializer: (params) => qs.stringify(params, { arrayFormat: "repeat" }),1169                            $return_headers: true,1170                        })1171                            .catch((e) => {1172                            this.logger.error(formatErrors(e));1173                            throw e;1174                        });1175                        const checkIsReadable = () => {1176                            const consumedError = "The stream has already been consumed";1177                            if (!res.data.readable) {1178                                this.logger.error(consumedError);1179                                throw new Error(consumedError);1180                            }1181                        };1182                        return {1183                            writeFile: (filePath) => __awaiter(this, void 0, void 0, function* () {1184                                checkIsReadable();1185                                return new Promise((resolve, reject) => {1186                                    const writableStream = fs__default["default"].createWriteStream(filePath);1187                                    writableStream.on("finish", () => {1188                                        resolve(filePath);1189                                    });1190                                    writableStream.on("error", (e) => {1191                                        reject(e);1192                                    });1193                                    res.data.pipe(writableStream);1194                                });1195                            }),1196                            getReadableStream: () => {1197                                checkIsReadable();1198                                return res.data;1199                            },1200                            headers: res.headers,

Showing the first 1,200 of 93682 lines. Download the file for the rest.

basant307/AI_Governance_Project · CoolFace