@ones-open/node-sdk 0.0.4-16596.20 → 0.0.4-21670.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4,24 +4,20 @@ const _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty")
4
4
  const lodashEs = require("lodash-es");
5
5
  const Fetch = require("axios");
6
6
  const _sortInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/sort");
7
- const getPlatformApiHost = () => {
8
- return "platformApiHost";
7
+ const getONESHostedBaseUrl = () => {
8
+ return process.env.ONES_HOSTED_BASE_URL;
9
9
  };
10
- const getPlatformAPIHost = getPlatformApiHost;
11
- const getInstanceId = () => {
12
- return "instanceId";
10
+ const getONESHostedAppID = () => {
11
+ return process.env.ONES_HOSTED_APP_ID;
13
12
  };
14
- const getApplicationId = () => {
15
- return "applicationId";
13
+ const getONESHostedToken = () => {
14
+ return process.env.ONES_HOSTED_TOKEN;
16
15
  };
17
- const getAppId = getApplicationId;
18
16
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
19
17
  __proto__: null,
20
- getAppId,
21
- getApplicationId,
22
- getInstanceId,
23
- getPlatformAPIHost,
24
- getPlatformApiHost
18
+ getONESHostedAppID,
19
+ getONESHostedBaseUrl,
20
+ getONESHostedToken
25
21
  }, Symbol.toStringTag, { value: "Module" }));
26
22
  var EntityWhereConditionEnum = /* @__PURE__ */ ((EntityWhereConditionEnum2) => {
27
23
  EntityWhereConditionEnum2["beginsWith"] = "beginsWith";
@@ -123,24 +119,37 @@ const createErrorResult = (code, message, error) => {
123
119
  }, error);
124
120
  };
125
121
  const fetch$1 = Fetch.create();
122
+ const buildAuthHeaders$1 = () => {
123
+ const token = getONESHostedToken();
124
+ if (token) {
125
+ return {
126
+ Authorization: `Bearer ${token}`
127
+ };
128
+ }
129
+ return {};
130
+ };
126
131
  const fetchBase$1 = (path, params, config) => {
127
- return Promise.all([getPlatformAPIHost(), getInstanceId()]).then((_ref) => {
128
- let [base, instance_id] = _ref;
129
- if (base && instance_id) {
130
- const url = `${base}${path}`;
132
+ return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
133
+ let [base, appId] = _ref;
134
+ if (base && appId) {
135
+ var _config$headers;
136
+ const url = `${base}/hosted_ability/storage/${appId}${path}`;
131
137
  const data = {
132
- ...params,
133
- instance_id
138
+ ...params
134
139
  };
135
140
  return fetch$1({
136
141
  ...config,
142
+ headers: {
143
+ ...(_config$headers = config === null || config === void 0 ? void 0 : config.headers) !== null && _config$headers !== void 0 ? _config$headers : {},
144
+ ...buildAuthHeaders$1()
145
+ },
137
146
  url,
138
147
  data
139
148
  });
140
149
  }
141
150
  throw new Error(JSON.stringify({
142
151
  base,
143
- instance_id
152
+ appId
144
153
  }));
145
154
  }).then((response) => {
146
155
  return response.data;
@@ -157,22 +166,22 @@ const fetchBase$1 = (path, params, config) => {
157
166
  });
158
167
  };
159
168
  const fetchPost = (params) => {
160
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data", params, {
169
+ return fetchBase$1(`/entity_data`, params, {
161
170
  method: "post"
162
171
  });
163
172
  };
164
173
  const fetchDelete$1 = (params) => {
165
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data", params, {
174
+ return fetchBase$1(`/entity_data`, params, {
166
175
  method: "delete"
167
176
  });
168
177
  };
169
178
  const fetchQuery = (params) => {
170
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data/get_many", params, {
179
+ return fetchBase$1(`/entity_data/get_many`, params, {
171
180
  method: "post"
172
181
  });
173
182
  };
174
183
  const fetchCount = (params) => {
175
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data/count", params, {
184
+ return fetchBase$1(`/entity_data/count`, params, {
176
185
  method: "post"
177
186
  });
178
187
  };
@@ -406,20 +415,30 @@ class ObjectError {
406
415
  }
407
416
  }
408
417
  const fetch = Fetch.create();
418
+ const buildAuthHeaders = () => {
419
+ const token = getONESHostedToken();
420
+ if (token) {
421
+ return {
422
+ Authorization: `Bearer ${token}`
423
+ };
424
+ }
425
+ return {};
426
+ };
409
427
  const fetchBase = (path, params) => {
410
- return Promise.all([getPlatformAPIHost(), getInstanceId()]).then((_ref) => {
411
- let [base, instance_id] = _ref;
412
- if (base && instance_id) {
413
- const url = `${base}${path}`;
428
+ return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
429
+ let [base, appId] = _ref;
430
+ if (base && appId) {
431
+ const url = `${base}/hosted_ability/storage/${appId}${path}`;
414
432
  const data = {
415
- ...params,
416
- instance_id
433
+ ...params
417
434
  };
418
- return fetch.post(url, data);
435
+ return fetch.post(url, data, {
436
+ headers: buildAuthHeaders()
437
+ });
419
438
  }
420
439
  throw new Error(JSON.stringify({
421
440
  base,
422
- instance_id
441
+ appId
423
442
  }));
424
443
  }).then((response) => {
425
444
  return response.data;
@@ -436,16 +455,16 @@ const fetchBase = (path, params) => {
436
455
  });
437
456
  };
438
457
  const fetchUpload = (params) => {
439
- return fetchBase("/plugin_ability_fetch/storage/object/get_upload_policy_info", params);
458
+ return fetchBase(`/object/get_upload_policy_info`, params);
440
459
  };
441
460
  const fetchDownload = (params) => {
442
- return fetchBase("/plugin_ability_fetch/storage/object/get_download_pre_signed_url", params);
461
+ return fetchBase(`/object/get_download_pre_signed_url`, params);
443
462
  };
444
463
  const fetchDelete = (params) => {
445
- return fetchBase("/plugin_ability_fetch/storage/object/delete", params);
464
+ return fetchBase(`/object/delete`, params);
446
465
  };
447
466
  const fetchMetadata = (params) => {
448
- return fetchBase("/plugin_ability_fetch/storage/object/get_metadata", params);
467
+ return fetchBase(`/object/get_metadata`, params);
449
468
  };
450
469
  const object = {
451
470
  ObjectError,
@@ -455,7 +474,8 @@ const object = {
455
474
  object_key: key
456
475
  });
457
476
  if (result.code === "OK") {
458
- if (result.data) {
477
+ var _result$data;
478
+ if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.url) {
459
479
  const {
460
480
  url,
461
481
  fields
package/dist/index.js CHANGED
@@ -2,24 +2,20 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
2
  import { isNull, isUndefined, isSymbol, set } from "lodash-es";
3
3
  import Fetch, { AxiosError } from "axios";
4
4
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
5
- const getPlatformApiHost = () => {
6
- return "platformApiHost";
5
+ const getONESHostedBaseUrl = () => {
6
+ return process.env.ONES_HOSTED_BASE_URL;
7
7
  };
8
- const getPlatformAPIHost = getPlatformApiHost;
9
- const getInstanceId = () => {
10
- return "instanceId";
8
+ const getONESHostedAppID = () => {
9
+ return process.env.ONES_HOSTED_APP_ID;
11
10
  };
12
- const getApplicationId = () => {
13
- return "applicationId";
11
+ const getONESHostedToken = () => {
12
+ return process.env.ONES_HOSTED_TOKEN;
14
13
  };
15
- const getAppId = getApplicationId;
16
14
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17
15
  __proto__: null,
18
- getAppId,
19
- getApplicationId,
20
- getInstanceId,
21
- getPlatformAPIHost,
22
- getPlatformApiHost
16
+ getONESHostedAppID,
17
+ getONESHostedBaseUrl,
18
+ getONESHostedToken
23
19
  }, Symbol.toStringTag, { value: "Module" }));
24
20
  var EntityWhereConditionEnum = /* @__PURE__ */ ((EntityWhereConditionEnum2) => {
25
21
  EntityWhereConditionEnum2["beginsWith"] = "beginsWith";
@@ -121,24 +117,37 @@ const createErrorResult = (code, message, error) => {
121
117
  }, error);
122
118
  };
123
119
  const fetch$1 = Fetch.create();
120
+ const buildAuthHeaders$1 = () => {
121
+ const token = getONESHostedToken();
122
+ if (token) {
123
+ return {
124
+ Authorization: `Bearer ${token}`
125
+ };
126
+ }
127
+ return {};
128
+ };
124
129
  const fetchBase$1 = (path, params, config) => {
125
- return Promise.all([getPlatformAPIHost(), getInstanceId()]).then((_ref) => {
126
- let [base, instance_id] = _ref;
127
- if (base && instance_id) {
128
- const url = `${base}${path}`;
130
+ return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
131
+ let [base, appId] = _ref;
132
+ if (base && appId) {
133
+ var _config$headers;
134
+ const url = `${base}/hosted_ability/storage/${appId}${path}`;
129
135
  const data = {
130
- ...params,
131
- instance_id
136
+ ...params
132
137
  };
133
138
  return fetch$1({
134
139
  ...config,
140
+ headers: {
141
+ ...(_config$headers = config === null || config === void 0 ? void 0 : config.headers) !== null && _config$headers !== void 0 ? _config$headers : {},
142
+ ...buildAuthHeaders$1()
143
+ },
135
144
  url,
136
145
  data
137
146
  });
138
147
  }
139
148
  throw new Error(JSON.stringify({
140
149
  base,
141
- instance_id
150
+ appId
142
151
  }));
143
152
  }).then((response) => {
144
153
  return response.data;
@@ -155,22 +164,22 @@ const fetchBase$1 = (path, params, config) => {
155
164
  });
156
165
  };
157
166
  const fetchPost = (params) => {
158
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data", params, {
167
+ return fetchBase$1(`/entity_data`, params, {
159
168
  method: "post"
160
169
  });
161
170
  };
162
171
  const fetchDelete$1 = (params) => {
163
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data", params, {
172
+ return fetchBase$1(`/entity_data`, params, {
164
173
  method: "delete"
165
174
  });
166
175
  };
167
176
  const fetchQuery = (params) => {
168
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data/get_many", params, {
177
+ return fetchBase$1(`/entity_data/get_many`, params, {
169
178
  method: "post"
170
179
  });
171
180
  };
172
181
  const fetchCount = (params) => {
173
- return fetchBase$1("/plugin_ability_fetch/storage/entity_data/count", params, {
182
+ return fetchBase$1(`/entity_data/count`, params, {
174
183
  method: "post"
175
184
  });
176
185
  };
@@ -404,20 +413,30 @@ class ObjectError {
404
413
  }
405
414
  }
406
415
  const fetch = Fetch.create();
416
+ const buildAuthHeaders = () => {
417
+ const token = getONESHostedToken();
418
+ if (token) {
419
+ return {
420
+ Authorization: `Bearer ${token}`
421
+ };
422
+ }
423
+ return {};
424
+ };
407
425
  const fetchBase = (path, params) => {
408
- return Promise.all([getPlatformAPIHost(), getInstanceId()]).then((_ref) => {
409
- let [base, instance_id] = _ref;
410
- if (base && instance_id) {
411
- const url = `${base}${path}`;
426
+ return Promise.all([getONESHostedBaseUrl(), getONESHostedAppID()]).then((_ref) => {
427
+ let [base, appId] = _ref;
428
+ if (base && appId) {
429
+ const url = `${base}/hosted_ability/storage/${appId}${path}`;
412
430
  const data = {
413
- ...params,
414
- instance_id
431
+ ...params
415
432
  };
416
- return fetch.post(url, data);
433
+ return fetch.post(url, data, {
434
+ headers: buildAuthHeaders()
435
+ });
417
436
  }
418
437
  throw new Error(JSON.stringify({
419
438
  base,
420
- instance_id
439
+ appId
421
440
  }));
422
441
  }).then((response) => {
423
442
  return response.data;
@@ -434,16 +453,16 @@ const fetchBase = (path, params) => {
434
453
  });
435
454
  };
436
455
  const fetchUpload = (params) => {
437
- return fetchBase("/plugin_ability_fetch/storage/object/get_upload_policy_info", params);
456
+ return fetchBase(`/object/get_upload_policy_info`, params);
438
457
  };
439
458
  const fetchDownload = (params) => {
440
- return fetchBase("/plugin_ability_fetch/storage/object/get_download_pre_signed_url", params);
459
+ return fetchBase(`/object/get_download_pre_signed_url`, params);
441
460
  };
442
461
  const fetchDelete = (params) => {
443
- return fetchBase("/plugin_ability_fetch/storage/object/delete", params);
462
+ return fetchBase(`/object/delete`, params);
444
463
  };
445
464
  const fetchMetadata = (params) => {
446
- return fetchBase("/plugin_ability_fetch/storage/object/get_metadata", params);
465
+ return fetchBase(`/object/get_metadata`, params);
447
466
  };
448
467
  const object = {
449
468
  ObjectError,
@@ -453,7 +472,8 @@ const object = {
453
472
  object_key: key
454
473
  });
455
474
  if (result.code === "OK") {
456
- if (result.data) {
475
+ var _result$data;
476
+ if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.url) {
457
477
  const {
458
478
  url,
459
479
  fields
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/entity/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,oBAAoB,EAEpB,qBAAqB,EAErB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;AA8CvB,eAAO,MAAM,SAAS,EAAE,mBAQvB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAQzB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAYxB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAQxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/entity/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,oBAAoB,EAEpB,qBAAqB,EAErB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;AA2DvB,eAAO,MAAM,SAAS,EAAE,mBAIvB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAYxB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,oBAIxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/object/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,qBAAqB,EAErB,uBAAuB,EAEvB,qBAAqB,EAErB,uBAAuB,EAExB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;AAyCvB,eAAO,MAAM,WAAW,EAAE,qBAKzB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,uBAK3B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAKzB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,uBAK3B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/packages/node/storage/object/fetch/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,qBAAqB,EAErB,uBAAuB,EAEvB,qBAAqB,EAErB,uBAAuB,EAExB,MAAM,SAAS,CAAA;AAEhB,cAAc,SAAS,CAAA;AAwDvB,eAAO,MAAM,WAAW,EAAE,qBAKzB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,uBAK3B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAEzB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,uBAE3B,CAAA"}
@@ -1,35 +1,14 @@
1
1
  /**
2
2
  * @description 获取开放平台 host
3
- * @alias getPlatformApiHost
4
- * @alias getPlatformAPIHost
5
- * @returns platformApiHost
3
+ * @alias getONESHostedBaseUrl
4
+ * @returns onesHostedBaseUrl
6
5
  */
7
- export declare const getPlatformApiHost: () => string;
8
- /**
9
- * @description 获取开放平台 host
10
- * @alias getPlatformApiHost
11
- * @alias getPlatformAPIHost
12
- * @returns platformApiHost
13
- */
14
- export declare const getPlatformAPIHost: () => string;
6
+ export declare const getONESHostedBaseUrl: () => string | undefined;
15
7
  /**
16
8
  * @description 获取插件实例 ID
17
- * @alias getInstanceId
18
- * @returns instanceId
19
- */
20
- export declare const getInstanceId: () => string;
21
- /**
22
- * @description 获取插件 ID
23
- * @alias getApplicationId
24
- * @alias getAppId
25
- * @returns applicationId
26
- */
27
- export declare const getApplicationId: () => string;
28
- /**
29
- * @description 获取插件 ID
30
- * @alias getApplicationId
31
- * @alias getAppId
32
- * @returns applicationId
9
+ * @alias getONESHostedAppID
10
+ * @returns onesHostedAppID
33
11
  */
34
- export declare const getAppId: () => string;
12
+ export declare const getONESHostedAppID: () => string | undefined;
13
+ export declare const getONESHostedToken: () => string | undefined;
35
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packages/strict/env/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAE9B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAAqB,CAAA;AAEpD;;;;GAIG;AACH,eAAO,MAAM,aAAa,cAEzB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,cAE5B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,cAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/packages/strict/env/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,0BAEhC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,0BAE9B,CAAA;AAED,eAAO,MAAM,kBAAkB,0BAE9B,CAAA"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ones-open/node-sdk",
3
- "version": "0.0.4-16596.20+f6d673af",
3
+ "version": "0.0.4-21670.121+c1d371f0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
8
+ "types": "./dist/types/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/types/index.d.ts",
@@ -50,5 +50,5 @@
50
50
  "devDependencies": {
51
51
  "@types/lodash-es": "^4.17.12"
52
52
  },
53
- "gitHead": "f6d673afd6cf6be57f22405055b91260d1f51f10"
53
+ "gitHead": "c1d371f0bbc77b4c211c8f0c4a9b49e024450e52"
54
54
  }