@code.store/arcxp-sdk-ts 4.15.0 → 4.16.1

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.
@@ -6,4 +6,5 @@ export declare class ArcDraft extends ArcAbstractAPI {
6
6
  unpublishDocument(id: string, type?: string): Promise<Revision>;
7
7
  deleteDocument(id: string, type?: string): Promise<Document>;
8
8
  createRedirect<P extends CreateRedirectPayload, R = P extends CreateExternalRedirectPayload ? ExternalRedirect : P extends CreateDocumentRedirectPayload ? DocumentRedirect : never>(website: string, websiteUrl: string, payload: P): Promise<R>;
9
+ getRedirect(website: string, websiteUrl: string): Promise<DocumentRedirect | ExternalRedirect>;
9
10
  }
@@ -22,6 +22,10 @@ class ArcDraft extends abstract_api_1.ArcAbstractAPI {
22
22
  const { data } = await this.client.post(`/redirect/${website}/${websiteUrl}`, payload);
23
23
  return data;
24
24
  }
25
+ async getRedirect(website, websiteUrl) {
26
+ const { data } = await this.client.get(`/redirect/${website}/${websiteUrl}`);
27
+ return data;
28
+ }
25
29
  }
26
30
  exports.ArcDraft = ArcDraft;
27
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/draft/index.ts"],"names":[],"mappings":";;;AAAA,kDAAgE;AAWhE,MAAa,QAAS,SAAQ,6BAAc;IAC1C,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAiB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EAAU,EAAE,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,MAAM,CAAW,IAAI,IAAI,IAAI,EAAE,qBAAqB,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU,EAAE,IAAI,GAAG,OAAO;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAW,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAOlB,OAAe,EAAE,UAAkB,EAAE,OAAU;QAC/C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAI,aAAa,OAAO,IAAI,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,UAAkB;QACnD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAsC,aAAa,OAAO,IAAI,UAAU,EAAE,CAAC,CAAC;QAClH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AApCD,4BAoCC"}
@@ -4,7 +4,7 @@ export type Distributor = {
4
4
  description: string;
5
5
  organizationId: string;
6
6
  archived: boolean;
7
- category: string;
7
+ category?: 'staff' | 'wires' | 'freelance' | 'stock' | 'handout' | 'other';
8
8
  subcategory: string;
9
9
  allowAll: boolean;
10
10
  createdAt: string;
@@ -1,7 +1,10 @@
1
1
  import { AnImage } from '../../types/story';
2
2
  import { ArcAbstractAPI, ArcAPIOptions } from '../abstract-api';
3
+ import { GetImagesParams, GetImagesResponse } from './types';
3
4
  export declare class ArcProtoCenter extends ArcAbstractAPI {
4
5
  constructor(options: ArcAPIOptions);
5
- getImageDataById(photoId: string): Promise<AnImage>;
6
+ getImageDataById(imageId: string): Promise<AnImage>;
6
7
  uploadImageANS(image: AnImage): Promise<AnImage>;
8
+ deleteImage(imageId: string): Promise<any>;
9
+ getImages(params: GetImagesParams): Promise<GetImagesResponse>;
7
10
  }
@@ -10,8 +10,8 @@ class ArcProtoCenter extends abstract_api_1.ArcAbstractAPI {
10
10
  constructor(options) {
11
11
  super({ ...options, apiPath: 'photo/api' });
12
12
  }
13
- async getImageDataById(photoId) {
14
- const { data } = await this.client.get(`/v2/photos/${photoId}`);
13
+ async getImageDataById(imageId) {
14
+ const { data } = await this.client.get(`/v2/photos/${imageId}`);
15
15
  return data;
16
16
  }
17
17
  async uploadImageANS(image) {
@@ -23,6 +23,14 @@ class ArcProtoCenter extends abstract_api_1.ArcAbstractAPI {
23
23
  const { data } = await this.client.post(`/v2/photos`, form, { headers: form.getHeaders() });
24
24
  return data;
25
25
  }
26
+ async deleteImage(imageId) {
27
+ const { data } = await this.client.delete(`/v2/photos/${imageId}`);
28
+ return data;
29
+ }
30
+ async getImages(params) {
31
+ const { data } = await this.client.get(`/v2/photos`, { params });
32
+ return data;
33
+ }
26
34
  }
27
35
  exports.ArcProtoCenter = ArcProtoCenter;
28
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/photo-center/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAiC;AAEjC,kDAAgE;AAEhE,MAAa,cAAe,SAAQ,6BAAc;IAChD,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,KAAK,CAAC,gBAAgB,CAAC,OAAe;QACpC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAc;QACjC,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;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;IACd,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAuB;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAoB,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5BD,wCA4BC"}
@@ -1 +1,7 @@
1
- export {};
1
+ import { AnImage } from '../../types/story';
2
+ export type GetImagesParams = Partial<{
3
+ primaryWebsite: string;
4
+ offset: number;
5
+ limit: number;
6
+ }>;
7
+ export type GetImagesResponse = AnImage[];
@@ -1,9 +1,11 @@
1
1
  import { Section, SetSection } from '../../types/section';
2
2
  import { ArcAbstractAPI, ArcAPIOptions } from '../abstract-api';
3
- import { Website } from './types';
3
+ import { GetSectionsResponse, Website } from './types';
4
4
  export declare class ArcSite extends ArcAbstractAPI {
5
5
  constructor(options: ArcAPIOptions);
6
+ getSections(website: string, offset?: number): Promise<GetSectionsResponse>;
6
7
  getSection(id: string, website: string): Promise<Section>;
8
+ deleteSection(id: string, website: string): Promise<void>;
7
9
  putSection(section: SetSection): Promise<any>;
8
10
  getWebsites(): Promise<Website[]>;
9
11
  }
@@ -6,10 +6,19 @@ class ArcSite extends abstract_api_1.ArcAbstractAPI {
6
6
  constructor(options) {
7
7
  super({ ...options, apiPath: 'site/v3' });
8
8
  }
9
+ async getSections(website, offset) {
10
+ const { data } = await this.client.get(`/website/${website}/section`, {
11
+ params: { _website: website, offset },
12
+ });
13
+ return data;
14
+ }
9
15
  async getSection(id, website) {
10
16
  const { data } = await this.client.get(`/website/${website}/section?_id=${id}`);
11
17
  return data;
12
18
  }
19
+ async deleteSection(id, website) {
20
+ await this.client.delete(`/website/${website}/section?_id=${id}`);
21
+ }
13
22
  async putSection(section) {
14
23
  const { data } = await this.client.put(`/website/${section.website}/section?_id=${section._id}`, section);
15
24
  return data;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/site/index.ts"],"names":[],"mappings":";;;AACA,kDAAgE;AAGhE,MAAa,OAAQ,SAAQ,6BAAc;IACzC,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU,EAAE,OAAe;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAU,YAAY,OAAO,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAmB;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,OAAO,gBAAgB,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAE1G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,UAAU,CAAC,CAAC;QAE9D,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtBD,0BAsBC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/site/index.ts"],"names":[],"mappings":";;;AACA,kDAAgE;AAGhE,MAAa,OAAQ,SAAQ,6BAAc;IACzC,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,MAAe;QAChD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAsB,YAAY,OAAO,UAAU,EAAE;YACzF,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;SACtC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU,EAAE,OAAe;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAU,YAAY,OAAO,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU,EAAE,OAAe;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,OAAO,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAmB;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,OAAO,gBAAgB,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAE1G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,UAAU,CAAC,CAAC;QAE9D,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlCD,0BAkCC"}
@@ -1,3 +1,4 @@
1
+ import { Section } from '../../types/section';
1
2
  export type Website = {
2
3
  _id: string;
3
4
  display_name: string;
@@ -5,3 +6,10 @@ export type Website = {
5
6
  is_default_website: boolean;
6
7
  domains: string[];
7
8
  };
9
+ export type GetSectionsResponse = {
10
+ count: number;
11
+ limit: number;
12
+ offset: number;
13
+ total_count: number;
14
+ q_results: Section[];
15
+ };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { ContentElement, ContentElementType } from './content-elements';
3
3
  import { WsClient } from './api/ws.client';
4
4
  import { ArcError } from './api/error';
5
5
  import * as ArcTypes from './types';
6
+ import { ArcUtils } from './utils/arc';
6
7
  export * from './api/identity/types';
7
8
  export * from './api/draft/types';
8
9
  export * from './api/site/types';
@@ -14,4 +15,4 @@ export * from './api/websked/types';
14
15
  export * from './api/content/types';
15
16
  export * from './api/photo-center/types';
16
17
  export * from './api/global-settings/types';
17
- export { ArcAPI, WsClient, ContentElement, ContentElementType, ArcTypes, ArcError };
18
+ export { ArcAPI, ArcUtils, WsClient, ContentElement, ContentElementType, ArcTypes, ArcError };
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ArcError = exports.ArcTypes = exports.ContentElement = exports.WsClient = exports.ArcAPI = void 0;
29
+ exports.ArcError = exports.ArcTypes = exports.ContentElement = exports.WsClient = exports.ArcUtils = exports.ArcAPI = void 0;
30
30
  const api_1 = require("./api");
31
31
  Object.defineProperty(exports, "ArcAPI", { enumerable: true, get: function () { return api_1.ArcAPI; } });
32
32
  const content_elements_1 = require("./content-elements");
@@ -37,6 +37,8 @@ const error_1 = require("./api/error");
37
37
  Object.defineProperty(exports, "ArcError", { enumerable: true, get: function () { return error_1.ArcError; } });
38
38
  const ArcTypes = __importStar(require("./types"));
39
39
  exports.ArcTypes = ArcTypes;
40
+ const arc_1 = require("./utils/arc");
41
+ Object.defineProperty(exports, "ArcUtils", { enumerable: true, get: function () { return arc_1.ArcUtils; } });
40
42
  __exportStar(require("./api/identity/types"), exports);
41
43
  __exportStar(require("./api/draft/types"), exports);
42
44
  __exportStar(require("./api/site/types"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAkBtB,uFAlBA,YAAM,OAkBA;AAjBf,yDAAwE;AAiB7C,+FAjBlB,iCAAc,OAiBkB;AAhBzC,+CAA2C;AAgB1B,yFAhBR,oBAAQ,OAgBQ;AAfzB,uCAAuC;AAekC,yFAfhE,gBAAQ,OAegE;AAdjF,kDAAoC;AAc2B,4BAAQ;AAZvE,uDAAqC;AACrC,oDAAkC;AAClC,mDAAiC;AACjC,kDAAgC;AAChC,uDAAqC;AACrC,+DAA6C;AAC7C,oDAAkC;AAClC,sDAAoC;AACpC,sDAAoC;AACpC,2DAAyC;AACzC,8DAA4C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAmBtB,uFAnBA,YAAM,OAmBA;AAlBf,yDAAwE;AAkBnC,+FAlB5B,iCAAc,OAkB4B;AAjBnD,+CAA2C;AAiBhB,yFAjBlB,oBAAQ,OAiBkB;AAhBnC,uCAAuC;AAgB4C,yFAhB1E,gBAAQ,OAgB0E;AAf3F,kDAAoC;AAeqC,4BAAQ;AAdjF,qCAAuC;AActB,yFAdR,cAAQ,OAcQ;AAZzB,uDAAqC;AACrC,oDAAkC;AAClC,mDAAiC;AACjC,kDAAgC;AAChC,uDAAqC;AACrC,+DAA6C;AAC7C,oDAAkC;AAClC,sDAAoC;AACpC,sDAAoC;AACpC,2DAAyC;AACzC,8DAA4C"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const arc_1 = require("../../utils/arc");
5
+ (0, vitest_1.describe)('Arc Utils', () => {
6
+ const namespace = `${Date.now()}`;
7
+ (0, vitest_1.beforeEach)(() => {
8
+ vitest_1.vi.resetAllMocks();
9
+ vitest_1.vi.clearAllMocks();
10
+ });
11
+ (0, vitest_1.describe)('ArcUtils.common.generateArcId', () => {
12
+ (0, vitest_1.test)('Should have 26 characters', () => {
13
+ const id = arc_1.ArcUtils.common.generateArcId('1', namespace);
14
+ (0, vitest_1.expect)(id).toHaveLength(26);
15
+ });
16
+ (0, vitest_1.test)('Same identifiers and namespaces', () => {
17
+ const id1 = arc_1.ArcUtils.common.generateArcId('1', namespace);
18
+ const id2 = arc_1.ArcUtils.common.generateArcId('1', namespace);
19
+ (0, vitest_1.expect)(id1).toEqual(id2);
20
+ });
21
+ (0, vitest_1.test)('Different identifiers', () => {
22
+ const id1 = arc_1.ArcUtils.common.generateArcId('1', namespace);
23
+ const id2 = arc_1.ArcUtils.common.generateArcId('2', namespace);
24
+ (0, vitest_1.expect)(id1).not.toEqual(id2);
25
+ });
26
+ (0, vitest_1.test)('Different namespaces', () => {
27
+ const id1 = arc_1.ArcUtils.common.generateArcId('1', namespace);
28
+ const id2 = arc_1.ArcUtils.common.generateArcId('1', namespace + '1');
29
+ (0, vitest_1.expect)(id1).not.toEqual(id2);
30
+ });
31
+ });
32
+ });
33
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../src/tests/api/utils.test.ts"],"names":[],"mappings":";;AAAA,mCAAgE;AAChE,yCAA2C;AAE3C,IAAA,iBAAQ,EAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAElC,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,WAAE,CAAC,aAAa,EAAE,CAAC;QACnB,WAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,+BAA+B,EAAE,GAAG,EAAE;QA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,GAAG,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const generateArcId: (identifier: string, orgHostname: string) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateArcId = void 0;
7
+ const base32_encode_1 = __importDefault(require("base32-encode"));
8
+ const uuid_1 = require("uuid");
9
+ const generateArcId = (identifier, orgHostname) => {
10
+ const namespace = (0, uuid_1.v5)(orgHostname, uuid_1.v5.DNS);
11
+ const buffer = (0, uuid_1.v5)(identifier, namespace, Buffer.alloc(16));
12
+ return (0, base32_encode_1.default)(buffer, 'RFC4648', { padding: false });
13
+ };
14
+ exports.generateArcId = generateArcId;
15
+ //# sourceMappingURL=generate-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-id.js","sourceRoot":"","sources":["../../../src/utils/arc/generate-id.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAmC;AACnC,+BAAoC;AAE7B,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,WAAmB,EAAE,EAAE;IACvE,MAAM,SAAS,GAAG,IAAA,SAAM,EAAC,WAAW,EAAE,SAAM,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,IAAA,SAAM,EAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,OAAO,IAAA,uBAAM,EAAC,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB"}
@@ -0,0 +1,5 @@
1
+ export declare const ArcUtils: {
2
+ common: {
3
+ generateArcId: (identifier: string, orgHostname: string) => string;
4
+ };
5
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArcUtils = void 0;
4
+ const generate_id_1 = require("./generate-id");
5
+ exports.ArcUtils = {
6
+ common: {
7
+ generateArcId: generate_id_1.generateArcId,
8
+ },
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/arc/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAEjC,QAAA,QAAQ,GAAG;IACtB,MAAM,EAAE;QACN,aAAa,EAAb,2BAAa;KACd;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code.store/arcxp-sdk-ts",
3
- "version": "4.15.0",
3
+ "version": "4.16.1",
4
4
  "description": "A strongly typed set of ArcXP API's and utilities reduce the amount of work required to develop with ArcXP, starting with reducing the boilerplate code you have to write.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",
@@ -36,22 +36,25 @@
36
36
  "@changesets/cli": "^2.26.2",
37
37
  "axios": "^1.4.0",
38
38
  "axios-rate-limit": "^1.3.0",
39
+ "base32-encode": "^1.2.0",
39
40
  "form-data": "^4.0.0",
41
+ "uuid": "^9.0.1",
40
42
  "ws": "^8.14.0"
41
43
  },
42
44
  "devDependencies": {
43
- "typescript": "^5.3.3",
44
45
  "@types/node": "^20.0.0",
45
46
  "@types/tap": "^15.0.8",
47
+ "@types/uuid": "^9.0.7",
46
48
  "@types/ws": "^8.5.5",
47
49
  "@typescript-eslint/eslint-plugin": "^5.47.1",
48
50
  "@typescript-eslint/parser": "^5.47.1",
49
51
  "eslint": "^8.31.0",
50
52
  "eslint-config-custom-server": "*",
51
- "openapi-typescript": "^6.2.7",
52
53
  "json-schema-to-typescript": "13.1.1",
54
+ "openapi-typescript": "^6.2.7",
53
55
  "tap": "^16.3.4",
54
56
  "ts-node-dev": "^2.0.0",
57
+ "typescript": "^5.3.3",
55
58
  "vitest": "^0.33.0"
56
59
  }
57
60
  }