@localess/js-client 0.2.3-next.20241220-130649.0 → 0.2.3-next.20241220-135957.0

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.
Files changed (74) hide show
  1. package/dist/cjs/client.d.ts +88 -0
  2. package/dist/cjs/client.js +170 -0
  3. package/dist/cjs/client.js.map +1 -0
  4. package/dist/cjs/editable.d.ts +7 -0
  5. package/dist/cjs/editable.js +10 -0
  6. package/dist/cjs/editable.js.map +1 -0
  7. package/dist/cjs/index.d.ts +20 -0
  8. package/dist/cjs/index.js +21 -0
  9. package/dist/cjs/index.js.map +1 -0
  10. package/dist/cjs/models/content-asset.d.ts +13 -0
  11. package/dist/cjs/models/content-asset.js +3 -0
  12. package/dist/cjs/models/content-asset.js.map +1 -0
  13. package/dist/cjs/models/content-data.d.ts +4 -0
  14. package/dist/cjs/models/content-data.js +3 -0
  15. package/dist/cjs/models/content-data.js.map +1 -0
  16. package/dist/cjs/models/content-link.d.ts +21 -0
  17. package/dist/cjs/models/content-link.js +3 -0
  18. package/dist/cjs/models/content-link.js.map +1 -0
  19. package/dist/cjs/models/content-metadata.d.ts +41 -0
  20. package/dist/cjs/models/content-metadata.js +3 -0
  21. package/dist/cjs/models/content-metadata.js.map +1 -0
  22. package/dist/cjs/models/content-rich-text.d.ts +13 -0
  23. package/dist/cjs/models/content-rich-text.js +3 -0
  24. package/dist/cjs/models/content-rich-text.js.map +1 -0
  25. package/dist/cjs/models/content.d.ts +47 -0
  26. package/dist/cjs/models/content.js +3 -0
  27. package/dist/cjs/models/content.js.map +1 -0
  28. package/dist/cjs/models/index.d.ts +8 -0
  29. package/dist/cjs/models/index.js +25 -0
  30. package/dist/cjs/models/index.js.map +1 -0
  31. package/dist/cjs/models/links.d.ts +7 -0
  32. package/dist/cjs/models/links.js +3 -0
  33. package/dist/cjs/models/links.js.map +1 -0
  34. package/dist/cjs/models/translations.d.ts +6 -0
  35. package/dist/cjs/models/translations.js +3 -0
  36. package/dist/cjs/models/translations.js.map +1 -0
  37. package/dist/cjs/sync.d.ts +6 -0
  38. package/dist/cjs/sync.js +32 -0
  39. package/dist/cjs/sync.js.map +1 -0
  40. package/dist/cjs/utils.d.ts +40 -0
  41. package/dist/cjs/utils.js +51 -0
  42. package/dist/cjs/utils.js.map +1 -0
  43. package/dist/client.d.ts +1 -1
  44. package/dist/client.js +163 -0
  45. package/dist/client.js.map +1 -0
  46. package/dist/editable.js +6 -0
  47. package/dist/editable.js.map +1 -0
  48. package/dist/index.js +5 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/models/content-asset.js +2 -0
  51. package/dist/models/content-asset.js.map +1 -0
  52. package/dist/models/content-data.js +2 -0
  53. package/dist/models/content-data.js.map +1 -0
  54. package/dist/models/content-link.js +2 -0
  55. package/dist/models/content-link.js.map +1 -0
  56. package/dist/models/content-metadata.js +2 -0
  57. package/dist/models/content-metadata.js.map +1 -0
  58. package/dist/models/content-rich-text.js +2 -0
  59. package/dist/models/content-rich-text.js.map +1 -0
  60. package/dist/models/content.js +2 -0
  61. package/dist/models/content.js.map +1 -0
  62. package/dist/models/index.js +9 -0
  63. package/dist/models/index.js.map +1 -0
  64. package/dist/models/links.js +2 -0
  65. package/dist/models/links.js.map +1 -0
  66. package/dist/models/translations.js +2 -0
  67. package/dist/models/translations.js.map +1 -0
  68. package/dist/sync.js +28 -0
  69. package/dist/sync.js.map +1 -0
  70. package/dist/utils.js +47 -0
  71. package/dist/utils.js.map +1 -0
  72. package/package.json +9 -11
  73. package/dist/localess-js.js +0 -51
  74. package/dist/localess-js.mjs +0 -22076
@@ -0,0 +1,88 @@
1
+ import { Content, ContentAsset, Links, Translations } from "./models";
2
+ export type LocalessClientOptions = {
3
+ /**
4
+ * A fully qualified domain name with protocol (http/https) and port.
5
+ *
6
+ * Example: https://my-localess.web.app
7
+ */
8
+ origin: string;
9
+ /**
10
+ * Localess space ID, cna be found in the Localess Space settings
11
+ */
12
+ spaceId: string;
13
+ /**
14
+ * Localess API token, can be found in the Localess Space settings
15
+ */
16
+ token: string;
17
+ /**
18
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
19
+ */
20
+ version?: 'draft' | string;
21
+ /**
22
+ * Enable debug mode
23
+ */
24
+ debug?: boolean;
25
+ };
26
+ export type LinksFetchParams = {
27
+ /**
28
+ * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
29
+ * @example 'DOCUMENT'
30
+ */
31
+ kind?: 'DOCUMENT' | 'FOLDER';
32
+ /**
33
+ * Content parent slug.
34
+ * @example 'legal/policy'
35
+ */
36
+ parentSlug?: string;
37
+ /**
38
+ * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
39
+ * @example false
40
+ */
41
+ excludeChildren?: boolean;
42
+ };
43
+ export type ContentFetchParams = {
44
+ /**
45
+ * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
46
+ * Overrides the version set in the client options.
47
+ */
48
+ version?: 'draft' | string;
49
+ /**
50
+ * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
51
+ *
52
+ * Example: en
53
+ */
54
+ locale?: string;
55
+ };
56
+ /**
57
+ * Create a Localess API Client
58
+ * @param {LocalessClientOptions} options connection details
59
+ */
60
+ export declare function localessClient(options: LocalessClientOptions): {
61
+ /**
62
+ * Get all links
63
+ * @param params{LinksFetchParams} - Fetch parameters
64
+ * @returns {Promise<Links>}
65
+ */
66
+ getLinks(params?: LinksFetchParams): Promise<Links>;
67
+ /**
68
+ * Get content by SLUG
69
+ * @param slug{string} - Content SLUG
70
+ * @param params{ContentFetchParams} - Fetch parameters
71
+ * @returns {Promise<Content>}
72
+ */
73
+ getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
74
+ /**
75
+ * Get content by ID
76
+ * @param id{string} - Content ID
77
+ * @param params{ContentFetchParams} - Fetch parameters
78
+ * @returns {Promise<Content>}
79
+ */
80
+ getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
81
+ /**
82
+ * Get translations for the given locale
83
+ * @param locale{string} - Locale identifier (ISO 639-1)
84
+ */
85
+ getTranslations(locale: string): Promise<Translations>;
86
+ syncScriptUrl(): string;
87
+ assetLink(asset: ContentAsset | string): string;
88
+ };
@@ -0,0 +1,170 @@
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.localessClient = void 0;
7
+ const utils_1 = require("./utils");
8
+ const node_fetch_1 = __importDefault(require("node-fetch"));
9
+ const proxy_agent_1 = require("proxy-agent");
10
+ const LOG_GROUP = `${utils_1.FG_BLUE}[Localess:Client]${utils_1.RESET}`;
11
+ /**
12
+ * Create a Localess API Client
13
+ * @param {LocalessClientOptions} options connection details
14
+ */
15
+ function localessClient(options) {
16
+ if (options.debug) {
17
+ console.log(LOG_GROUP, 'Client Options : ', options);
18
+ }
19
+ const fetchOptions = {
20
+ redirect: 'follow',
21
+ };
22
+ if ((0, utils_1.proxyURIFromEnv)()) {
23
+ if (options.debug) {
24
+ console.log(LOG_GROUP, 'Proxy Agent Enabled');
25
+ }
26
+ fetchOptions.agent = new proxy_agent_1.ProxyAgent();
27
+ }
28
+ return {
29
+ /**
30
+ * Get all links
31
+ * @param params{LinksFetchParams} - Fetch parameters
32
+ * @returns {Promise<Links>}
33
+ */
34
+ async getLinks(params) {
35
+ if (options.debug) {
36
+ console.log(LOG_GROUP, 'getLinks() params : ' + params);
37
+ }
38
+ let kind = '';
39
+ if (params?.kind) {
40
+ kind = `&kind=${params.kind}`;
41
+ }
42
+ let parentSlug = '';
43
+ if (params?.parentSlug) {
44
+ parentSlug = `&parentSlug=${params.parentSlug}`;
45
+ }
46
+ let excludeChildren = '';
47
+ if (params?.excludeChildren) {
48
+ excludeChildren = `&excludeChildren=${params.excludeChildren}`;
49
+ }
50
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}${kind}${parentSlug}${excludeChildren}`;
51
+ if (options.debug) {
52
+ console.log(LOG_GROUP, 'getLinks fetch url : ', url);
53
+ }
54
+ try {
55
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
56
+ if (options.debug) {
57
+ console.log(LOG_GROUP, 'getLinks status : ', response.status);
58
+ }
59
+ const data = await response.json();
60
+ return data;
61
+ }
62
+ catch (error) {
63
+ console.error(LOG_GROUP, 'getLinks error : ', error);
64
+ return {};
65
+ }
66
+ },
67
+ /**
68
+ * Get content by SLUG
69
+ * @param slug{string} - Content SLUG
70
+ * @param params{ContentFetchParams} - Fetch parameters
71
+ * @returns {Promise<Content>}
72
+ */
73
+ async getContentBySlug(slug, params) {
74
+ if (options.debug) {
75
+ console.log(LOG_GROUP, 'getContentBySlug() slug : ', slug);
76
+ console.log(LOG_GROUP, 'getContentBySlug() params : ', params);
77
+ }
78
+ let version = '';
79
+ // Options
80
+ if (options?.version && options.version == 'draft') {
81
+ version = `&version=${options.version}`;
82
+ }
83
+ // Params
84
+ if (params?.version && params.version == 'draft') {
85
+ version = `&version=${params.version}`;
86
+ }
87
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
88
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
89
+ if (options.debug) {
90
+ console.log(LOG_GROUP, 'getContentBySlug fetch url : ', url);
91
+ }
92
+ try {
93
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
94
+ if (options.debug) {
95
+ console.log(LOG_GROUP, 'getContentBySlug status : ', response.status);
96
+ }
97
+ const data = await response.json();
98
+ return data;
99
+ }
100
+ catch (error) {
101
+ console.error(LOG_GROUP, 'getContentBySlug error : ', error);
102
+ return {};
103
+ }
104
+ },
105
+ /**
106
+ * Get content by ID
107
+ * @param id{string} - Content ID
108
+ * @param params{ContentFetchParams} - Fetch parameters
109
+ * @returns {Promise<Content>}
110
+ */
111
+ async getContentById(id, params) {
112
+ if (options.debug) {
113
+ console.log(LOG_GROUP, 'getContentById() id : ', id);
114
+ console.log(LOG_GROUP, 'getContentById() params : ', params);
115
+ }
116
+ let version = '';
117
+ // Options
118
+ if (options?.version && options.version == 'draft') {
119
+ version = `&version=${options.version}`;
120
+ }
121
+ // Params
122
+ if (params?.version && params.version == 'draft') {
123
+ version = `&version=${params.version}`;
124
+ }
125
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
126
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
127
+ if (options.debug) {
128
+ console.log(LOG_GROUP, 'getContentById fetch url : ', url);
129
+ }
130
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
131
+ if (options.debug) {
132
+ console.log(LOG_GROUP, 'getContentById status : ', response.status);
133
+ }
134
+ const data = await response.json();
135
+ return data;
136
+ },
137
+ /**
138
+ * Get translations for the given locale
139
+ * @param locale{string} - Locale identifier (ISO 639-1)
140
+ */
141
+ async getTranslations(locale) {
142
+ if (options.debug) {
143
+ console.log(LOG_GROUP, 'getTranslations() locale : ', locale);
144
+ }
145
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
146
+ if (options.debug) {
147
+ console.log(LOG_GROUP, 'getTranslations fetch url : ', url);
148
+ }
149
+ const response = await (0, node_fetch_1.default)(url, fetchOptions);
150
+ if (options.debug) {
151
+ console.log(LOG_GROUP, 'getTranslations status : ', response.status);
152
+ }
153
+ const data = await response.json();
154
+ return data;
155
+ },
156
+ syncScriptUrl() {
157
+ return `${options.origin}/scripts/sync-v1.js`;
158
+ },
159
+ assetLink(asset) {
160
+ if (typeof asset === 'string') {
161
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
162
+ }
163
+ else {
164
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
165
+ }
166
+ }
167
+ };
168
+ }
169
+ exports.localessClient = localessClient;
170
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sour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AClC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,6BAA6B,EAAE,MAAM,CAAC,CAAC;YAChE,CAAC;YACD,IAAI,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,iBAAiB,MAAM,EAAE,CAAC;YACtF,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,8BAA8B,EAAE,GAAG,CAAC,CAAC;YAC9D,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE,YAAY,CAAC,CAAA;YAC/C,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACvE,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAoB,CAAC;QAC9B,CAAC;QAED,aAAa;YACX,OAAO,GAAG,OAAO,CAAC,MAAM,qBAAqB,CAAA;QAC/C,CAAC;QAED,SAAS,CAAC,KAA4B;YACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,EAAE,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA7JD,wCA6JC"}
@@ -0,0 +1,7 @@
1
+ export type ContentDataSkeleton = {
2
+ _id: string;
3
+ schema: string;
4
+ };
5
+ export declare function llEditable(content: ContentDataSkeleton): {
6
+ 'data-ll-id': string;
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.llEditable = void 0;
4
+ function llEditable(content) {
5
+ return {
6
+ 'data-ll-id': content._id
7
+ };
8
+ }
9
+ exports.llEditable = llEditable;
10
+ //# sourceMappingURL=editable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editable.js","sourceRoot":"","sources":["../../src/editable.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,OAA4B;IACrD,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,GAAG;KAC1B,CAAA;AACH,CAAC;AAJD,gCAIC"}
@@ -0,0 +1,20 @@
1
+ export * from './models';
2
+ export * from './client';
3
+ export * from './editable';
4
+ export * from './sync';
5
+ declare global {
6
+ type EventType = 'input' | 'save' | 'publish' | 'change';
7
+ type EventCallback = (event: EventToApp) => void;
8
+ type EventToApp = {
9
+ type: 'save' | 'publish';
10
+ } | {
11
+ type: 'input' | 'change';
12
+ data: any;
13
+ };
14
+ interface LocalessSync {
15
+ on: (event: EventType | EventType[], callback: EventCallback) => void;
16
+ }
17
+ interface Window {
18
+ localess?: LocalessSync;
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./models"), exports);
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./editable"), exports);
20
+ __exportStar(require("./sync"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B;AAC3B,yCAAuB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Content Asset define reference to a Asset.
3
+ */
4
+ export interface ContentAsset {
5
+ /**
6
+ * Define the type of Asset
7
+ */
8
+ kind: 'ASSET';
9
+ /**
10
+ * Unique identifier for the asset.
11
+ */
12
+ uri: string;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content-asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-asset.js","sourceRoot":"","sources":["../../../src/models/content-asset.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ContentData defined Object to connect all possible root Schemas.
3
+ */
4
+ export type ContentData = any;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-data.js","sourceRoot":"","sources":["../../../src/models/content-data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Content Link define reference to a Link.
3
+ */
4
+ export interface ContentLink {
5
+ /**
6
+ * Define the type of Link
7
+ */
8
+ kind: 'LINK';
9
+ /**
10
+ * Define the target of the link. _blank for new tab and _self for same tab.
11
+ */
12
+ target: '_blank' | '_self';
13
+ /**
14
+ * Define the type of Link. URL for external links and Content for internal links.
15
+ */
16
+ type: 'url' | 'content';
17
+ /**
18
+ * If type is content, then it will be Content ID. Otherwise it will be URL.
19
+ */
20
+ uri: string;
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-link.js","sourceRoot":"","sources":["../../../src/models/content-link.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Content Metadata define short information about a Content for navigation reason.
3
+ */
4
+ export interface ContentMetadata {
5
+ /**
6
+ * Date and Time at which the Content was created.
7
+ */
8
+ createdAt: string;
9
+ /**
10
+ * Combination of SLUG and Parent SLUG of the Content
11
+ */
12
+ fullSlug: string;
13
+ /**
14
+ * Unique identifier for the object.
15
+ */
16
+ id: string;
17
+ /**
18
+ * Define the type of Content, whether it is a FOLDER or DOCUMENT.
19
+ */
20
+ kind: 'FOLDER' | 'DOCUMENT';
21
+ /**
22
+ * Name of the Content
23
+ */
24
+ name: string;
25
+ /**
26
+ * Parent SLUG of the Content
27
+ */
28
+ parentSlug: string;
29
+ /**
30
+ * Date and Time at which the Content was published.
31
+ */
32
+ publishedAt?: string;
33
+ /**
34
+ * SLUG of the Content
35
+ */
36
+ slug: string;
37
+ /**
38
+ * Date and Time at which the Content was updated.
39
+ */
40
+ updatedAt: string;
41
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-metadata.js","sourceRoot":"","sources":["../../../src/models/content-metadata.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Content RichText define content as JSON Object.
3
+ */
4
+ export interface ContentRichText {
5
+ /**
6
+ * Define the type of Content Node
7
+ */
8
+ type?: string;
9
+ /**
10
+ * List of Content Nodes
11
+ */
12
+ content?: ContentRichText[];
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content-rich-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-rich-text.js","sourceRoot":"","sources":["../../../src/models/content-rich-text.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ import { ContentData } from './content-data';
2
+ /**
3
+ * Content define shared object for all possible Content Types.
4
+ */
5
+ export interface Content {
6
+ /**
7
+ * Date and Time at which the Content was created.
8
+ */
9
+ createdAt: string;
10
+ data?: ContentData;
11
+ /**
12
+ * Combination of SLUG and Parent SLUG of the Content
13
+ */
14
+ fullSlug: string;
15
+ /**
16
+ * Unique identifier for the object.
17
+ */
18
+ id: string;
19
+ /**
20
+ * Define the type of Content, whether it is a FOLDER or DOCUMENT.
21
+ */
22
+ kind: 'FOLDER' | 'DOCUMENT';
23
+ /**
24
+ * Locale unique identifier (ISO 639-1).
25
+ */
26
+ locale?: string;
27
+ /**
28
+ * Name of the Content
29
+ */
30
+ name: string;
31
+ /**
32
+ * Parent SLUG of the Content
33
+ */
34
+ parentSlug: string;
35
+ /**
36
+ * Date and Time at which the Content was published.
37
+ */
38
+ publishedAt?: string;
39
+ /**
40
+ * SLUG of the Content
41
+ */
42
+ slug: string;
43
+ /**
44
+ * Date and Time at which the Content was updated.
45
+ */
46
+ updatedAt: string;
47
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/models/content.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export * from './content';
2
+ export * from './content-asset';
3
+ export * from './content-data';
4
+ export * from './content-link';
5
+ export * from './content-metadata';
6
+ export * from './content-rich-text';
7
+ export * from './links';
8
+ export * from './translations';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./content"), exports);
18
+ __exportStar(require("./content-asset"), exports);
19
+ __exportStar(require("./content-data"), exports);
20
+ __exportStar(require("./content-link"), exports);
21
+ __exportStar(require("./content-metadata"), exports);
22
+ __exportStar(require("./content-rich-text"), exports);
23
+ __exportStar(require("./links"), exports);
24
+ __exportStar(require("./translations"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,kDAAgC;AAChC,iDAA+B;AAC/B,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AACpC,0CAAwB;AACxB,iDAA+B"}
@@ -0,0 +1,7 @@
1
+ import { ContentMetadata } from './content-metadata';
2
+ /**
3
+ * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
4
+ */
5
+ export interface Links {
6
+ [key: string]: ContentMetadata;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.js","sourceRoot":"","sources":["../../../src/models/links.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Key-Value Object. Where Key is Translation ID and Value is Translated Content
3
+ */
4
+ export interface Translations {
5
+ [key: string]: string;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.js","sourceRoot":"","sources":["../../../src/models/translations.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Inject Localess Sync Script in Header
3
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
4
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
5
+ */
6
+ export declare function loadLocalessSync(origin: string, force?: boolean): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadLocalessSync = void 0;
4
+ const JS_SYNC_ID = 'localess-js-sync';
5
+ /**
6
+ * Inject Localess Sync Script in Header
7
+ * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
8
+ * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
9
+ */
10
+ function loadLocalessSync(origin, force = false) {
11
+ const isServer = typeof window === 'undefined';
12
+ if (isServer)
13
+ return; // Skip Server Injection
14
+ if (window.top === window.self)
15
+ return; // Skip if the page is not loaded in Visual Editor
16
+ const isSyncLoaded = typeof window.localess !== 'undefined';
17
+ if (isSyncLoaded)
18
+ return; // Skip if Sync is already loaded
19
+ const scriptEl = document.getElementById(JS_SYNC_ID);
20
+ if (scriptEl)
21
+ return; // Skip if script is already loaded
22
+ const script = document.createElement('script');
23
+ script.id = JS_SYNC_ID;
24
+ script.type = 'text/javascript';
25
+ script.src = `${origin}/scripts/sync-v1.js`;
26
+ script.async = true;
27
+ script.onerror = (error) => console.error(error);
28
+ script.onload = (event) => console.info('Localess Sync Script loaded');
29
+ document.head.appendChild(script);
30
+ }
31
+ exports.loadLocalessSync = loadLocalessSync;
32
+ //# sourceMappingURL=sync.js.map