@timbenniks/contentstack-platform-sdk 0.1.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.
- package/dist/auth/index.cjs +607 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +108 -0
- package/dist/auth/index.d.ts +108 -0
- package/dist/auth/index.mjs +25 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/brandkit/index.cjs +525 -0
- package/dist/brandkit/index.cjs.map +1 -0
- package/dist/brandkit/index.d.cts +95 -0
- package/dist/brandkit/index.d.ts +95 -0
- package/dist/brandkit/index.mjs +11 -0
- package/dist/brandkit/index.mjs.map +1 -0
- package/dist/chunk-3C6J2BDB.mjs +84 -0
- package/dist/chunk-3C6J2BDB.mjs.map +1 -0
- package/dist/chunk-3KE63N3I.mjs +64 -0
- package/dist/chunk-3KE63N3I.mjs.map +1 -0
- package/dist/chunk-4CJ4IVPJ.mjs +212 -0
- package/dist/chunk-4CJ4IVPJ.mjs.map +1 -0
- package/dist/chunk-4JFUI7MJ.mjs +368 -0
- package/dist/chunk-4JFUI7MJ.mjs.map +1 -0
- package/dist/chunk-7VFGD32I.mjs +26 -0
- package/dist/chunk-7VFGD32I.mjs.map +1 -0
- package/dist/chunk-ARPJDW3A.mjs +44 -0
- package/dist/chunk-ARPJDW3A.mjs.map +1 -0
- package/dist/chunk-AVJHCFRK.mjs +52 -0
- package/dist/chunk-AVJHCFRK.mjs.map +1 -0
- package/dist/chunk-BK2IBTQS.mjs +131 -0
- package/dist/chunk-BK2IBTQS.mjs.map +1 -0
- package/dist/chunk-BUZ6CQHE.mjs +75 -0
- package/dist/chunk-BUZ6CQHE.mjs.map +1 -0
- package/dist/chunk-CKMAOWBQ.mjs +379 -0
- package/dist/chunk-CKMAOWBQ.mjs.map +1 -0
- package/dist/chunk-DJQLN4TR.mjs +1 -0
- package/dist/chunk-DJQLN4TR.mjs.map +1 -0
- package/dist/chunk-DMERADWM.mjs +67 -0
- package/dist/chunk-DMERADWM.mjs.map +1 -0
- package/dist/chunk-EREPKWTW.mjs +926 -0
- package/dist/chunk-EREPKWTW.mjs.map +1 -0
- package/dist/chunk-FQP4PB5X.mjs +88 -0
- package/dist/chunk-FQP4PB5X.mjs.map +1 -0
- package/dist/chunk-GNPQJBFX.mjs +144 -0
- package/dist/chunk-GNPQJBFX.mjs.map +1 -0
- package/dist/chunk-GOSB24M6.mjs +87 -0
- package/dist/chunk-GOSB24M6.mjs.map +1 -0
- package/dist/chunk-JL2E3EOT.mjs +255 -0
- package/dist/chunk-JL2E3EOT.mjs.map +1 -0
- package/dist/chunk-JYGZBKTH.mjs +222 -0
- package/dist/chunk-JYGZBKTH.mjs.map +1 -0
- package/dist/chunk-JZE2W7VW.mjs +52 -0
- package/dist/chunk-JZE2W7VW.mjs.map +1 -0
- package/dist/chunk-K76DKSHJ.mjs +18 -0
- package/dist/chunk-K76DKSHJ.mjs.map +1 -0
- package/dist/chunk-KLVIROVU.mjs +232 -0
- package/dist/chunk-KLVIROVU.mjs.map +1 -0
- package/dist/chunk-LPVVA5J3.mjs +18 -0
- package/dist/chunk-LPVVA5J3.mjs.map +1 -0
- package/dist/chunk-NKLOZ5VI.mjs +112 -0
- package/dist/chunk-NKLOZ5VI.mjs.map +1 -0
- package/dist/chunk-QGA4WBDC.mjs +7 -0
- package/dist/chunk-QGA4WBDC.mjs.map +1 -0
- package/dist/chunk-QW7TVYOA.mjs +56 -0
- package/dist/chunk-QW7TVYOA.mjs.map +1 -0
- package/dist/chunk-SU5QEKYW.mjs +83 -0
- package/dist/chunk-SU5QEKYW.mjs.map +1 -0
- package/dist/chunk-T5A2E2RI.mjs +654 -0
- package/dist/chunk-T5A2E2RI.mjs.map +1 -0
- package/dist/chunk-T5OIJQK7.mjs +116 -0
- package/dist/chunk-T5OIJQK7.mjs.map +1 -0
- package/dist/chunk-VW7DD6HV.mjs +253 -0
- package/dist/chunk-VW7DD6HV.mjs.map +1 -0
- package/dist/chunk-XH7NLHGW.mjs +133 -0
- package/dist/chunk-XH7NLHGW.mjs.map +1 -0
- package/dist/client-DJ5haQGd.d.cts +22 -0
- package/dist/client-DwVGVSQz.d.ts +22 -0
- package/dist/cma/index.cjs +1349 -0
- package/dist/cma/index.cjs.map +1 -0
- package/dist/cma/index.d.cts +22 -0
- package/dist/cma/index.d.ts +22 -0
- package/dist/cma/index.mjs +70 -0
- package/dist/cma/index.mjs.map +1 -0
- package/dist/errors-CAw-IRCP.d.cts +65 -0
- package/dist/errors-CAw-IRCP.d.ts +65 -0
- package/dist/generative-ai/index.cjs +401 -0
- package/dist/generative-ai/index.cjs.map +1 -0
- package/dist/generative-ai/index.d.cts +31 -0
- package/dist/generative-ai/index.d.ts +31 -0
- package/dist/generative-ai/index.mjs +10 -0
- package/dist/generative-ai/index.mjs.map +1 -0
- package/dist/images/index.cjs +185 -0
- package/dist/images/index.cjs.map +1 -0
- package/dist/images/index.d.cts +27 -0
- package/dist/images/index.d.ts +27 -0
- package/dist/images/index.mjs +8 -0
- package/dist/images/index.mjs.map +1 -0
- package/dist/index.cjs +2909 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.mjs +153 -0
- package/dist/index.mjs.map +1 -0
- package/dist/knowledge-vault/index.cjs +413 -0
- package/dist/knowledge-vault/index.cjs.map +1 -0
- package/dist/knowledge-vault/index.d.cts +49 -0
- package/dist/knowledge-vault/index.d.ts +49 -0
- package/dist/knowledge-vault/index.mjs +10 -0
- package/dist/knowledge-vault/index.mjs.map +1 -0
- package/dist/launch/index.cjs +624 -0
- package/dist/launch/index.cjs.map +1 -0
- package/dist/launch/index.d.cts +169 -0
- package/dist/launch/index.d.ts +169 -0
- package/dist/launch/index.mjs +11 -0
- package/dist/launch/index.mjs.map +1 -0
- package/dist/react/auth/index.cjs +113 -0
- package/dist/react/auth/index.cjs.map +1 -0
- package/dist/react/auth/index.d.cts +33 -0
- package/dist/react/auth/index.d.ts +33 -0
- package/dist/react/auth/index.mjs +13 -0
- package/dist/react/auth/index.mjs.map +1 -0
- package/dist/react/content/index.cjs +113 -0
- package/dist/react/content/index.cjs.map +1 -0
- package/dist/react/content/index.d.cts +25 -0
- package/dist/react/content/index.d.ts +25 -0
- package/dist/react/content/index.mjs +7 -0
- package/dist/react/content/index.mjs.map +1 -0
- package/dist/react/hooks/index.cjs +2097 -0
- package/dist/react/hooks/index.cjs.map +1 -0
- package/dist/react/hooks/index.d.cts +77 -0
- package/dist/react/hooks/index.d.ts +77 -0
- package/dist/react/hooks/index.mjs +46 -0
- package/dist/react/hooks/index.mjs.map +1 -0
- package/dist/react/index.cjs +2307 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +16 -0
- package/dist/react/index.d.ts +16 -0
- package/dist/react/index.mjs +67 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/provider/index.cjs +83 -0
- package/dist/react/provider/index.cjs.map +1 -0
- package/dist/react/provider/index.d.cts +30 -0
- package/dist/react/provider/index.d.ts +30 -0
- package/dist/react/provider/index.mjs +11 -0
- package/dist/react/provider/index.mjs.map +1 -0
- package/dist/regions/index.cjs +171 -0
- package/dist/regions/index.cjs.map +1 -0
- package/dist/regions/index.d.cts +55 -0
- package/dist/regions/index.d.ts +55 -0
- package/dist/regions/index.mjs +13 -0
- package/dist/regions/index.mjs.map +1 -0
- package/dist/request-builders-BxeolQIw.d.ts +735 -0
- package/dist/request-builders-C2IG1LUo.d.cts +735 -0
- package/dist/rte/index.cjs +683 -0
- package/dist/rte/index.cjs.map +1 -0
- package/dist/rte/index.d.cts +33 -0
- package/dist/rte/index.d.ts +33 -0
- package/dist/rte/index.mjs +17 -0
- package/dist/rte/index.mjs.map +1 -0
- package/dist/server/index.cjs +917 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +6 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.mjs +45 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/middleware/index.cjs +614 -0
- package/dist/server/middleware/index.cjs.map +1 -0
- package/dist/server/middleware/index.d.cts +77 -0
- package/dist/server/middleware/index.d.ts +77 -0
- package/dist/server/middleware/index.mjs +27 -0
- package/dist/server/middleware/index.mjs.map +1 -0
- package/dist/server/proxy/index.cjs +329 -0
- package/dist/server/proxy/index.cjs.map +1 -0
- package/dist/server/proxy/index.d.cts +143 -0
- package/dist/server/proxy/index.d.ts +143 -0
- package/dist/server/proxy/index.mjs +29 -0
- package/dist/server/proxy/index.mjs.map +1 -0
- package/dist/server/webhooks/index.cjs +131 -0
- package/dist/server/webhooks/index.cjs.map +1 -0
- package/dist/server/webhooks/index.d.cts +230 -0
- package/dist/server/webhooks/index.d.ts +230 -0
- package/dist/server/webhooks/index.mjs +23 -0
- package/dist/server/webhooks/index.mjs.map +1 -0
- package/dist/types-6D9VR7pT.d.cts +26 -0
- package/dist/types-AelT0rFJ.d.cts +21 -0
- package/dist/types-AelT0rFJ.d.ts +21 -0
- package/dist/types-Bu5yCgmw.d.ts +26 -0
- package/dist/types-DgixK-ll.d.cts +23 -0
- package/dist/types-DgixK-ll.d.ts +23 -0
- package/dist/types-DrMwdlH9.d.cts +245 -0
- package/dist/types-DrMwdlH9.d.ts +245 -0
- package/dist/ui/css/index.cjs +31 -0
- package/dist/ui/css/index.cjs.map +1 -0
- package/dist/ui/css/index.d.cts +15 -0
- package/dist/ui/css/index.d.ts +15 -0
- package/dist/ui/css/index.mjs +7 -0
- package/dist/ui/css/index.mjs.map +1 -0
- package/dist/ui/index.cjs +368 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +4 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.mjs +33 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/ui/theme/index.cjs +105 -0
- package/dist/ui/theme/index.cjs.map +1 -0
- package/dist/ui/theme/index.d.cts +33 -0
- package/dist/ui/theme/index.d.ts +33 -0
- package/dist/ui/theme/index.mjs +15 -0
- package/dist/ui/theme/index.mjs.map +1 -0
- package/dist/ui/tokens/index.cjs +286 -0
- package/dist/ui/tokens/index.cjs.map +1 -0
- package/dist/ui/tokens/index.d.cts +54 -0
- package/dist/ui/tokens/index.d.ts +54 -0
- package/dist/ui/tokens/index.mjs +17 -0
- package/dist/ui/tokens/index.mjs.map +1 -0
- package/dist/ui/tokens.css +408 -0
- package/dist/vue/auth/index.cjs +141 -0
- package/dist/vue/auth/index.cjs.map +1 -0
- package/dist/vue/auth/index.d.cts +78 -0
- package/dist/vue/auth/index.d.ts +78 -0
- package/dist/vue/auth/index.mjs +13 -0
- package/dist/vue/auth/index.mjs.map +1 -0
- package/dist/vue/composables/index.cjs +2108 -0
- package/dist/vue/composables/index.cjs.map +1 -0
- package/dist/vue/composables/index.d.cts +78 -0
- package/dist/vue/composables/index.d.ts +78 -0
- package/dist/vue/composables/index.mjs +46 -0
- package/dist/vue/composables/index.mjs.map +1 -0
- package/dist/vue/content/index.cjs +142 -0
- package/dist/vue/content/index.cjs.map +1 -0
- package/dist/vue/content/index.d.cts +47 -0
- package/dist/vue/content/index.d.ts +47 -0
- package/dist/vue/content/index.mjs +7 -0
- package/dist/vue/content/index.mjs.map +1 -0
- package/dist/vue/index.cjs +2389 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.cts +16 -0
- package/dist/vue/index.d.ts +16 -0
- package/dist/vue/index.mjs +69 -0
- package/dist/vue/index.mjs.map +1 -0
- package/dist/vue/provider/index.cjs +97 -0
- package/dist/vue/provider/index.cjs.map +1 -0
- package/dist/vue/provider/index.d.cts +90 -0
- package/dist/vue/provider/index.d.ts +90 -0
- package/dist/vue/provider/index.mjs +13 -0
- package/dist/vue/provider/index.mjs.map +1 -0
- package/package.json +195 -0
|
@@ -0,0 +1,2108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/vue/composables/index.ts
|
|
21
|
+
var composables_exports = {};
|
|
22
|
+
__export(composables_exports, {
|
|
23
|
+
useAssets: () => useAssets,
|
|
24
|
+
useBrandKit: () => useBrandKit,
|
|
25
|
+
useCMA: () => useCMA,
|
|
26
|
+
useContentTypes: () => useContentTypes,
|
|
27
|
+
useCreateEntry: () => useCreateEntry,
|
|
28
|
+
useDeleteEntry: () => useDeleteEntry,
|
|
29
|
+
useEntries: () => useEntries,
|
|
30
|
+
useEntry: () => useEntry,
|
|
31
|
+
useGenerativeAI: () => useGenerativeAI,
|
|
32
|
+
useKnowledgeVault: () => useKnowledgeVault,
|
|
33
|
+
useLaunch: () => useLaunch,
|
|
34
|
+
usePublishEntry: () => usePublishEntry,
|
|
35
|
+
useUpdateEntry: () => useUpdateEntry
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(composables_exports);
|
|
38
|
+
|
|
39
|
+
// src/vue/composables/useEntries.ts
|
|
40
|
+
var import_vue3 = require("vue");
|
|
41
|
+
|
|
42
|
+
// src/http/errors.ts
|
|
43
|
+
var ContentstackError = class extends Error {
|
|
44
|
+
name = "ContentstackError";
|
|
45
|
+
status;
|
|
46
|
+
errorCode;
|
|
47
|
+
errors;
|
|
48
|
+
requestPath;
|
|
49
|
+
constructor(message, options) {
|
|
50
|
+
super(message, options?.cause ? { cause: options.cause } : void 0);
|
|
51
|
+
this.status = options?.status;
|
|
52
|
+
this.errorCode = options?.errorCode;
|
|
53
|
+
this.errors = options?.errors;
|
|
54
|
+
this.requestPath = options?.requestPath;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ContentstackAuthError = class extends ContentstackError {
|
|
58
|
+
name = "ContentstackAuthError";
|
|
59
|
+
status = 401;
|
|
60
|
+
};
|
|
61
|
+
var ContentstackForbiddenError = class extends ContentstackError {
|
|
62
|
+
name = "ContentstackForbiddenError";
|
|
63
|
+
status = 403;
|
|
64
|
+
};
|
|
65
|
+
var ContentstackNotFoundError = class extends ContentstackError {
|
|
66
|
+
name = "ContentstackNotFoundError";
|
|
67
|
+
status = 404;
|
|
68
|
+
};
|
|
69
|
+
var ContentstackValidationError = class extends ContentstackError {
|
|
70
|
+
name = "ContentstackValidationError";
|
|
71
|
+
status;
|
|
72
|
+
constructor(message, options) {
|
|
73
|
+
super(message, options);
|
|
74
|
+
this.status = options?.status ?? 400;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var ContentstackInvalidApiKeyError = class extends ContentstackError {
|
|
78
|
+
name = "ContentstackInvalidApiKeyError";
|
|
79
|
+
status = 412;
|
|
80
|
+
};
|
|
81
|
+
var ContentstackRateLimitError = class extends ContentstackError {
|
|
82
|
+
name = "ContentstackRateLimitError";
|
|
83
|
+
status = 429;
|
|
84
|
+
retryAfter;
|
|
85
|
+
constructor(message, options) {
|
|
86
|
+
super(message, { ...options, status: 429 });
|
|
87
|
+
this.retryAfter = options?.retryAfter;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var ContentstackServerError = class extends ContentstackError {
|
|
91
|
+
name = "ContentstackServerError";
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/regions/endpoints.ts
|
|
95
|
+
var import_contentstack_endpoints = require("@timbenniks/contentstack-endpoints");
|
|
96
|
+
var BRAND_KIT_URLS = {
|
|
97
|
+
us: {
|
|
98
|
+
brandKit: "https://brand-kits-api.contentstack.com",
|
|
99
|
+
brandKitAI: "https://ai.contentstack.com/brand-kits"
|
|
100
|
+
},
|
|
101
|
+
eu: {
|
|
102
|
+
brandKit: "https://eu-brand-kits-api.contentstack.com",
|
|
103
|
+
brandKitAI: "https://eu-ai.contentstack.com/brand-kits"
|
|
104
|
+
},
|
|
105
|
+
au: {
|
|
106
|
+
brandKit: "https://au-brand-kits-api.contentstack.com",
|
|
107
|
+
brandKitAI: "https://au-ai.contentstack.com/brand-kits"
|
|
108
|
+
},
|
|
109
|
+
"azure-na": {
|
|
110
|
+
brandKit: "https://azure-na-brand-kits-api.contentstack.com",
|
|
111
|
+
brandKitAI: "https://azure-na-ai.contentstack.com/brand-kits"
|
|
112
|
+
},
|
|
113
|
+
"azure-eu": {
|
|
114
|
+
brandKit: "https://azure-eu-brand-kits-api.contentstack.com",
|
|
115
|
+
brandKitAI: "https://azure-eu-ai.contentstack.com/brand-kits"
|
|
116
|
+
},
|
|
117
|
+
"gcp-na": {
|
|
118
|
+
brandKit: "https://gcp-na-brand-kits-api.contentstack.com",
|
|
119
|
+
brandKitAI: "https://gcp-na-ai.contentstack.com/brand-kits"
|
|
120
|
+
},
|
|
121
|
+
"gcp-eu": {
|
|
122
|
+
brandKit: "https://gcp-eu-brand-kits-api.contentstack.com",
|
|
123
|
+
brandKitAI: "https://gcp-eu-ai.contentstack.com/brand-kits"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
function mapEndpoints(upstream, region, hostsOnly) {
|
|
127
|
+
const bk = BRAND_KIT_URLS[region];
|
|
128
|
+
const stripProtocol = (url) => url.replace(/^https?:\/\//, "");
|
|
129
|
+
return Object.freeze({
|
|
130
|
+
cma: upstream.contentManagement ?? "",
|
|
131
|
+
cda: upstream.contentDelivery ?? "",
|
|
132
|
+
graphql: upstream.graphqlDelivery ?? "",
|
|
133
|
+
images: upstream.images ?? "",
|
|
134
|
+
app: upstream.application ?? "",
|
|
135
|
+
preview: upstream.preview ?? "",
|
|
136
|
+
graphqlPreview: upstream.graphqlPreview ?? "",
|
|
137
|
+
launch: upstream.launch ?? "",
|
|
138
|
+
personalizeEdge: upstream.personalizeEdge ?? "",
|
|
139
|
+
brandKit: hostsOnly ? stripProtocol(bk.brandKit) : bk.brandKit,
|
|
140
|
+
brandKitAI: hostsOnly ? stripProtocol(bk.brandKitAI) : bk.brandKitAI
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
var ALL_REGIONS = [
|
|
144
|
+
"us",
|
|
145
|
+
"eu",
|
|
146
|
+
"au",
|
|
147
|
+
"azure-na",
|
|
148
|
+
"azure-eu",
|
|
149
|
+
"gcp-na",
|
|
150
|
+
"gcp-eu"
|
|
151
|
+
];
|
|
152
|
+
function buildEndpointMap() {
|
|
153
|
+
const map = {};
|
|
154
|
+
for (const region of ALL_REGIONS) {
|
|
155
|
+
map[region] = mapEndpoints((0, import_contentstack_endpoints.getContentstackEndpoints)(region), region, false);
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze(map);
|
|
158
|
+
}
|
|
159
|
+
function buildHostMap() {
|
|
160
|
+
const map = {};
|
|
161
|
+
for (const region of ALL_REGIONS) {
|
|
162
|
+
map[region] = mapEndpoints((0, import_contentstack_endpoints.getContentstackEndpoints)(region, true), region, true);
|
|
163
|
+
}
|
|
164
|
+
return Object.freeze(map);
|
|
165
|
+
}
|
|
166
|
+
var ENDPOINT_MAP = buildEndpointMap();
|
|
167
|
+
var HOST_MAP = buildHostMap();
|
|
168
|
+
|
|
169
|
+
// src/regions/resolver.ts
|
|
170
|
+
var VALID_REGIONS = new Set(Object.keys(ENDPOINT_MAP));
|
|
171
|
+
function resolveEndpoints(region) {
|
|
172
|
+
return ENDPOINT_MAP[region];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/http/parse-error.ts
|
|
176
|
+
async function parseErrorResponse(response, path) {
|
|
177
|
+
try {
|
|
178
|
+
const body = await response.json();
|
|
179
|
+
return new ContentstackError(body.error_message ?? body.message ?? response.statusText, {
|
|
180
|
+
status: response.status,
|
|
181
|
+
errorCode: body.error_code,
|
|
182
|
+
errors: body.errors,
|
|
183
|
+
requestPath: path
|
|
184
|
+
});
|
|
185
|
+
} catch {
|
|
186
|
+
return new ContentstackError(response.statusText, {
|
|
187
|
+
status: response.status,
|
|
188
|
+
requestPath: path
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/http/client.ts
|
|
194
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
195
|
+
var DEFAULT_RETRY_LIMIT = 5;
|
|
196
|
+
var DEFAULT_RETRY_DELAY = 300;
|
|
197
|
+
var MAX_JITTER = 100;
|
|
198
|
+
var ContentstackHttpClient = class _ContentstackHttpClient {
|
|
199
|
+
config;
|
|
200
|
+
constructor(config) {
|
|
201
|
+
this.config = {
|
|
202
|
+
baseUrl: config.baseUrl,
|
|
203
|
+
headers: config.headers ?? {},
|
|
204
|
+
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
205
|
+
retryOnError: config.retryOnError ?? true,
|
|
206
|
+
retryLimit: config.retryLimit ?? DEFAULT_RETRY_LIMIT,
|
|
207
|
+
retryDelay: config.retryDelay ?? DEFAULT_RETRY_DELAY,
|
|
208
|
+
fetch: config.fetch ?? globalThis.fetch.bind(globalThis)
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
async get(path, params) {
|
|
212
|
+
let url = `${this.config.baseUrl}${path}`;
|
|
213
|
+
if (params) {
|
|
214
|
+
const searchParams = new URLSearchParams(params);
|
|
215
|
+
url += `?${searchParams.toString()}`;
|
|
216
|
+
}
|
|
217
|
+
return this.request(url, { method: "GET" }, path);
|
|
218
|
+
}
|
|
219
|
+
async post(path, body) {
|
|
220
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
221
|
+
return this.request(
|
|
222
|
+
url,
|
|
223
|
+
{
|
|
224
|
+
method: "POST",
|
|
225
|
+
headers: { "Content-Type": "application/json" },
|
|
226
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
227
|
+
},
|
|
228
|
+
path
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
async put(path, body) {
|
|
232
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
233
|
+
return this.request(
|
|
234
|
+
url,
|
|
235
|
+
{
|
|
236
|
+
method: "PUT",
|
|
237
|
+
headers: { "Content-Type": "application/json" },
|
|
238
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
239
|
+
},
|
|
240
|
+
path
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
async patch(path, body) {
|
|
244
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
245
|
+
return this.request(
|
|
246
|
+
url,
|
|
247
|
+
{
|
|
248
|
+
method: "PATCH",
|
|
249
|
+
headers: { "Content-Type": "application/json" },
|
|
250
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
251
|
+
},
|
|
252
|
+
path
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
async delete(path) {
|
|
256
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
257
|
+
return this.request(url, { method: "DELETE" }, path);
|
|
258
|
+
}
|
|
259
|
+
async postForm(path, params) {
|
|
260
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
261
|
+
return this.request(
|
|
262
|
+
url,
|
|
263
|
+
{
|
|
264
|
+
method: "POST",
|
|
265
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
266
|
+
body: params.toString()
|
|
267
|
+
},
|
|
268
|
+
path
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
async upload(path, form) {
|
|
272
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
273
|
+
return this.request(url, { method: "POST", body: form }, path);
|
|
274
|
+
}
|
|
275
|
+
/** Return a new client with additional headers merged */
|
|
276
|
+
withHeaders(headers) {
|
|
277
|
+
return new _ContentstackHttpClient({
|
|
278
|
+
...this.config,
|
|
279
|
+
headers: { ...this.config.headers, ...headers }
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/** Return a new client with a different base URL */
|
|
283
|
+
withBaseUrl(baseUrl) {
|
|
284
|
+
return new _ContentstackHttpClient({
|
|
285
|
+
...this.config,
|
|
286
|
+
baseUrl
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async request(url, init, path) {
|
|
290
|
+
const headers = new Headers(this.config.headers);
|
|
291
|
+
if (init.headers) {
|
|
292
|
+
const initHeaders = init.headers instanceof Headers ? init.headers : new Headers(init.headers);
|
|
293
|
+
initHeaders.forEach((value, key) => headers.set(key, value));
|
|
294
|
+
}
|
|
295
|
+
let lastError;
|
|
296
|
+
const maxAttempts = this.config.retryOnError ? this.config.retryLimit + 1 : 1;
|
|
297
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
298
|
+
const controller = new AbortController();
|
|
299
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
300
|
+
try {
|
|
301
|
+
const response = await this.config.fetch(url, {
|
|
302
|
+
...init,
|
|
303
|
+
headers,
|
|
304
|
+
signal: controller.signal
|
|
305
|
+
});
|
|
306
|
+
if (response.ok) {
|
|
307
|
+
const data = await response.json().catch(() => ({}));
|
|
308
|
+
return { data, status: response.status, headers: response.headers };
|
|
309
|
+
}
|
|
310
|
+
const isRetryable = response.status === 429 || response.status >= 500;
|
|
311
|
+
if (isRetryable && this.config.retryOnError && attempt < maxAttempts - 1) {
|
|
312
|
+
const delay = this.calculateDelay(response, attempt);
|
|
313
|
+
await sleep(delay);
|
|
314
|
+
lastError = await this.createError(response, path);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
throw await this.createError(response, path);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (error instanceof ContentstackError) {
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
323
|
+
throw new ContentstackError(`Request timed out after ${this.config.timeout}ms`, {
|
|
324
|
+
requestPath: path,
|
|
325
|
+
cause: error
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
throw new ContentstackError("Network request failed", {
|
|
329
|
+
requestPath: path,
|
|
330
|
+
cause: error instanceof Error ? error : new Error(String(error))
|
|
331
|
+
});
|
|
332
|
+
} finally {
|
|
333
|
+
clearTimeout(timeoutId);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
throw lastError ?? new ContentstackError("Request failed after retries", { requestPath: path });
|
|
337
|
+
}
|
|
338
|
+
calculateDelay(response, attempt) {
|
|
339
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
340
|
+
if (retryAfter) {
|
|
341
|
+
const seconds = Number.parseFloat(retryAfter);
|
|
342
|
+
if (!Number.isNaN(seconds)) {
|
|
343
|
+
return seconds * 1e3;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const jitter = Math.random() * MAX_JITTER;
|
|
347
|
+
return this.config.retryDelay * 2 ** attempt + jitter;
|
|
348
|
+
}
|
|
349
|
+
async createError(response, path) {
|
|
350
|
+
let body = {};
|
|
351
|
+
try {
|
|
352
|
+
body = await response.json();
|
|
353
|
+
} catch {
|
|
354
|
+
}
|
|
355
|
+
const message = body.error_message ?? body.error_description ?? body.message ?? `HTTP ${response.status} error`;
|
|
356
|
+
const errorCode = body.error_code;
|
|
357
|
+
const errors = body.errors;
|
|
358
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
359
|
+
const opts = { status: response.status, errorCode, errors, requestPath: path };
|
|
360
|
+
switch (response.status) {
|
|
361
|
+
case 400:
|
|
362
|
+
return new ContentstackValidationError(message, { ...opts, status: 400 });
|
|
363
|
+
case 401:
|
|
364
|
+
return new ContentstackAuthError(message, opts);
|
|
365
|
+
case 403:
|
|
366
|
+
return new ContentstackForbiddenError(message, opts);
|
|
367
|
+
case 404:
|
|
368
|
+
return new ContentstackNotFoundError(message, opts);
|
|
369
|
+
case 412:
|
|
370
|
+
return new ContentstackInvalidApiKeyError(message, opts);
|
|
371
|
+
case 422:
|
|
372
|
+
return new ContentstackValidationError(message, { ...opts, status: 422 });
|
|
373
|
+
case 429:
|
|
374
|
+
return new ContentstackRateLimitError(message, {
|
|
375
|
+
...opts,
|
|
376
|
+
retryAfter: retryAfter ? Number.parseFloat(retryAfter) : void 0
|
|
377
|
+
});
|
|
378
|
+
default:
|
|
379
|
+
if (response.status >= 500) {
|
|
380
|
+
return new ContentstackServerError(message, opts);
|
|
381
|
+
}
|
|
382
|
+
return new ContentstackError(message, opts);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
function sleep(ms) {
|
|
387
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/cma/pagination.ts
|
|
391
|
+
var DEFAULT_PAGE_SIZE = 25;
|
|
392
|
+
function paginate(fetchPage, options) {
|
|
393
|
+
const pageSize = options?.limit ?? DEFAULT_PAGE_SIZE;
|
|
394
|
+
return {
|
|
395
|
+
[Symbol.asyncIterator]() {
|
|
396
|
+
let skip = 0;
|
|
397
|
+
let done = false;
|
|
398
|
+
let buffer = [];
|
|
399
|
+
let bufferIndex = 0;
|
|
400
|
+
let totalCount;
|
|
401
|
+
return {
|
|
402
|
+
async next() {
|
|
403
|
+
if (bufferIndex < buffer.length) {
|
|
404
|
+
return { value: buffer[bufferIndex++], done: false };
|
|
405
|
+
}
|
|
406
|
+
if (done) {
|
|
407
|
+
return { value: void 0, done: true };
|
|
408
|
+
}
|
|
409
|
+
const page = await fetchPage(skip, pageSize);
|
|
410
|
+
buffer = page.items;
|
|
411
|
+
bufferIndex = 0;
|
|
412
|
+
skip += page.items.length;
|
|
413
|
+
if (typeof page.count === "number") {
|
|
414
|
+
totalCount = page.count;
|
|
415
|
+
}
|
|
416
|
+
if (page.items.length === 0) {
|
|
417
|
+
done = true;
|
|
418
|
+
return { value: void 0, done: true };
|
|
419
|
+
}
|
|
420
|
+
if (typeof totalCount === "number" && skip >= totalCount) {
|
|
421
|
+
done = true;
|
|
422
|
+
}
|
|
423
|
+
return { value: buffer[bufferIndex++], done: false };
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
async function collectAll(iterable) {
|
|
430
|
+
const items = [];
|
|
431
|
+
for await (const item of iterable) {
|
|
432
|
+
items.push(item);
|
|
433
|
+
}
|
|
434
|
+
return items;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/cma/assets.ts
|
|
438
|
+
var AssetsClient = class {
|
|
439
|
+
constructor(http) {
|
|
440
|
+
this.http = http;
|
|
441
|
+
}
|
|
442
|
+
list(opts) {
|
|
443
|
+
return paginate(
|
|
444
|
+
async (skip, limit) => {
|
|
445
|
+
const params = {
|
|
446
|
+
skip: String(skip),
|
|
447
|
+
limit: String(limit)
|
|
448
|
+
};
|
|
449
|
+
if (opts?.folder) params.folder = opts.folder;
|
|
450
|
+
const response = await this.http.get("/assets", params);
|
|
451
|
+
return { items: response.data.assets ?? [], count: response.data.count };
|
|
452
|
+
},
|
|
453
|
+
{ limit: opts?.limit }
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
async listAll(opts) {
|
|
457
|
+
return collectAll(this.list(opts));
|
|
458
|
+
}
|
|
459
|
+
async get(uid) {
|
|
460
|
+
const response = await this.http.get(`/assets/${uid}`);
|
|
461
|
+
return response.data.asset;
|
|
462
|
+
}
|
|
463
|
+
async upload(form) {
|
|
464
|
+
const response = await this.http.upload("/assets", form);
|
|
465
|
+
return response.data.asset;
|
|
466
|
+
}
|
|
467
|
+
async update(uid, data) {
|
|
468
|
+
const response = await this.http.put(`/assets/${uid}`, { asset: data });
|
|
469
|
+
return response.data.asset;
|
|
470
|
+
}
|
|
471
|
+
async delete(uid) {
|
|
472
|
+
await this.http.delete(`/assets/${uid}`);
|
|
473
|
+
}
|
|
474
|
+
async publish(uid, data) {
|
|
475
|
+
await this.http.post(`/assets/${uid}/publish`, { asset: data });
|
|
476
|
+
}
|
|
477
|
+
async unpublish(uid, data) {
|
|
478
|
+
await this.http.post(`/assets/${uid}/unpublish`, { asset: data });
|
|
479
|
+
}
|
|
480
|
+
// ─── Folders ──────────────────────────────────────────────────────
|
|
481
|
+
async listFolders(opts) {
|
|
482
|
+
const response = await this.http.get("/assets/folders", {
|
|
483
|
+
limit: String(opts?.limit ?? 100)
|
|
484
|
+
});
|
|
485
|
+
return response.data.assets ?? [];
|
|
486
|
+
}
|
|
487
|
+
async getFolder(uid) {
|
|
488
|
+
const response = await this.http.get(`/assets/folders/${uid}`);
|
|
489
|
+
return response.data.asset;
|
|
490
|
+
}
|
|
491
|
+
async createFolder(data) {
|
|
492
|
+
const response = await this.http.post("/assets/folders", {
|
|
493
|
+
asset: data
|
|
494
|
+
});
|
|
495
|
+
return response.data.asset;
|
|
496
|
+
}
|
|
497
|
+
async updateFolder(uid, data) {
|
|
498
|
+
const response = await this.http.put(`/assets/folders/${uid}`, {
|
|
499
|
+
asset: data
|
|
500
|
+
});
|
|
501
|
+
return response.data.asset;
|
|
502
|
+
}
|
|
503
|
+
async deleteFolder(uid) {
|
|
504
|
+
await this.http.delete(`/assets/folders/${uid}`);
|
|
505
|
+
}
|
|
506
|
+
// ─── Additional Operations ──────────────────────────────────────
|
|
507
|
+
async replace(uid, form) {
|
|
508
|
+
const response = await this.http.upload(`/assets/${uid}`, form);
|
|
509
|
+
return response.data.asset;
|
|
510
|
+
}
|
|
511
|
+
async getReferences(uid) {
|
|
512
|
+
const response = await this.http.get(`/assets/${uid}/references`);
|
|
513
|
+
return response.data.references ?? [];
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
// src/cma/base-client.ts
|
|
518
|
+
var CrudClient = class {
|
|
519
|
+
constructor(http, config) {
|
|
520
|
+
this.http = http;
|
|
521
|
+
this.config = config;
|
|
522
|
+
}
|
|
523
|
+
list(opts) {
|
|
524
|
+
return paginate(
|
|
525
|
+
async (skip, limit) => {
|
|
526
|
+
const response = await this.http.get(this.config.basePath, {
|
|
527
|
+
skip: String(skip),
|
|
528
|
+
limit: String(limit)
|
|
529
|
+
});
|
|
530
|
+
const items = response.data[this.config.pluralKey] ?? [];
|
|
531
|
+
return { items, count: response.data.count };
|
|
532
|
+
},
|
|
533
|
+
{ limit: opts?.limit }
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
async listAll(opts) {
|
|
537
|
+
return collectAll(this.list(opts));
|
|
538
|
+
}
|
|
539
|
+
async get(uid) {
|
|
540
|
+
const response = await this.http.get(`${this.config.basePath}/${uid}`);
|
|
541
|
+
return response.data[this.config.singularKey];
|
|
542
|
+
}
|
|
543
|
+
async create(data) {
|
|
544
|
+
const response = await this.http.post(this.config.basePath, {
|
|
545
|
+
[this.config.singularKey]: data
|
|
546
|
+
});
|
|
547
|
+
return response.data[this.config.singularKey];
|
|
548
|
+
}
|
|
549
|
+
async update(uid, data) {
|
|
550
|
+
const response = await this.http.put(
|
|
551
|
+
`${this.config.basePath}/${uid}`,
|
|
552
|
+
{ [this.config.singularKey]: data }
|
|
553
|
+
);
|
|
554
|
+
return response.data[this.config.singularKey];
|
|
555
|
+
}
|
|
556
|
+
async delete(uid) {
|
|
557
|
+
await this.http.delete(`${this.config.basePath}/${uid}`);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// src/cma/audit-log.ts
|
|
562
|
+
var AuditLogClient = class extends CrudClient {
|
|
563
|
+
constructor(http) {
|
|
564
|
+
super(http, { basePath: "/audit-logs", singularKey: "audit_log", pluralKey: "audit_logs" });
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// src/cma/branch-aliases.ts
|
|
569
|
+
var BranchAliasesClient = class {
|
|
570
|
+
constructor(http) {
|
|
571
|
+
this.http = http;
|
|
572
|
+
}
|
|
573
|
+
async list() {
|
|
574
|
+
const response = await this.http.get(
|
|
575
|
+
"/stacks/branch_aliases"
|
|
576
|
+
);
|
|
577
|
+
return response.data.branch_aliases ?? [];
|
|
578
|
+
}
|
|
579
|
+
async get(uid) {
|
|
580
|
+
const response = await this.http.get(
|
|
581
|
+
`/stacks/branch_aliases/${uid}`
|
|
582
|
+
);
|
|
583
|
+
return response.data.branch_alias;
|
|
584
|
+
}
|
|
585
|
+
async createOrUpdate(uid, targetBranch) {
|
|
586
|
+
const response = await this.http.put(
|
|
587
|
+
`/stacks/branch_aliases/${uid}`,
|
|
588
|
+
{ branch_alias: { target_branch: targetBranch } }
|
|
589
|
+
);
|
|
590
|
+
return response.data.branch_alias;
|
|
591
|
+
}
|
|
592
|
+
async delete(uid) {
|
|
593
|
+
await this.http.delete(`/stacks/branch_aliases/${uid}`);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// src/cma/branches.ts
|
|
598
|
+
var BranchesClient = class {
|
|
599
|
+
constructor(http) {
|
|
600
|
+
this.http = http;
|
|
601
|
+
}
|
|
602
|
+
list(opts) {
|
|
603
|
+
return paginate(
|
|
604
|
+
async (skip, limit) => {
|
|
605
|
+
const response = await this.http.get(
|
|
606
|
+
"/stacks/branches",
|
|
607
|
+
{ skip: String(skip), limit: String(limit) }
|
|
608
|
+
);
|
|
609
|
+
return { items: response.data.branches ?? [], count: response.data.count };
|
|
610
|
+
},
|
|
611
|
+
{ limit: opts?.limit }
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
async listAll(opts) {
|
|
615
|
+
return collectAll(this.list(opts));
|
|
616
|
+
}
|
|
617
|
+
async get(uid) {
|
|
618
|
+
const response = await this.http.get(`/stacks/branches/${uid}`);
|
|
619
|
+
return response.data.branch;
|
|
620
|
+
}
|
|
621
|
+
async create(data) {
|
|
622
|
+
const response = await this.http.post("/stacks/branches", {
|
|
623
|
+
branch: data
|
|
624
|
+
});
|
|
625
|
+
return response.data.branch;
|
|
626
|
+
}
|
|
627
|
+
async delete(uid) {
|
|
628
|
+
await this.http.delete(`/stacks/branches/${uid}`);
|
|
629
|
+
}
|
|
630
|
+
async compare(baseBranch, compareBranch) {
|
|
631
|
+
const response = await this.http.get("/stacks/branches_compare", {
|
|
632
|
+
base_branch: baseBranch,
|
|
633
|
+
compare_branch: compareBranch
|
|
634
|
+
});
|
|
635
|
+
return response.data;
|
|
636
|
+
}
|
|
637
|
+
async merge(data) {
|
|
638
|
+
const response = await this.http.post("/stacks/branches_merge", data);
|
|
639
|
+
return response.data.merge_job;
|
|
640
|
+
}
|
|
641
|
+
async listMergeJobs() {
|
|
642
|
+
const response = await this.http.get("/stacks/branches_queue");
|
|
643
|
+
return response.data.merge_jobs ?? [];
|
|
644
|
+
}
|
|
645
|
+
async getMergeJob(uid) {
|
|
646
|
+
const response = await this.http.get(`/stacks/branches_queue/${uid}`);
|
|
647
|
+
return response.data.merge_job;
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/cma/bulk.ts
|
|
652
|
+
var BulkOperationsClient = class {
|
|
653
|
+
constructor(http) {
|
|
654
|
+
this.http = http;
|
|
655
|
+
}
|
|
656
|
+
async publish(data) {
|
|
657
|
+
await this.http.post("/bulk/publish", data);
|
|
658
|
+
}
|
|
659
|
+
async unpublish(data) {
|
|
660
|
+
await this.http.post("/bulk/unpublish", data);
|
|
661
|
+
}
|
|
662
|
+
async delete(data) {
|
|
663
|
+
await this.http.post("/bulk/delete", data);
|
|
664
|
+
}
|
|
665
|
+
async updateWorkflow(data) {
|
|
666
|
+
await this.http.post("/bulk/workflow", data);
|
|
667
|
+
}
|
|
668
|
+
async addItems(data) {
|
|
669
|
+
await this.http.post("/bulk/add", data);
|
|
670
|
+
}
|
|
671
|
+
async updateItems(data) {
|
|
672
|
+
await this.http.post("/bulk/update", data);
|
|
673
|
+
}
|
|
674
|
+
async jobStatus(jobId) {
|
|
675
|
+
const response = await this.http.get(`/bulk/jobs/${jobId}`);
|
|
676
|
+
return response.data.job;
|
|
677
|
+
}
|
|
678
|
+
async getJobItems(jobId, opts) {
|
|
679
|
+
const params = {};
|
|
680
|
+
if (opts?.limit) params.limit = String(opts.limit);
|
|
681
|
+
if (opts?.skip) params.skip = String(opts.skip);
|
|
682
|
+
const response = await this.http.get(
|
|
683
|
+
`/bulk/jobs/${jobId}/items`,
|
|
684
|
+
Object.keys(params).length > 0 ? params : void 0
|
|
685
|
+
);
|
|
686
|
+
return response.data.items ?? [];
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// src/cma/content-types.ts
|
|
691
|
+
var ContentTypesClient = class extends CrudClient {
|
|
692
|
+
constructor(http) {
|
|
693
|
+
super(http, {
|
|
694
|
+
basePath: "/content_types",
|
|
695
|
+
singularKey: "content_type",
|
|
696
|
+
pluralKey: "content_types"
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
list(opts) {
|
|
700
|
+
return paginate(
|
|
701
|
+
async (skip, limit) => {
|
|
702
|
+
const params = {
|
|
703
|
+
skip: String(skip),
|
|
704
|
+
limit: String(limit)
|
|
705
|
+
};
|
|
706
|
+
if (opts?.include_count) params.include_count = "true";
|
|
707
|
+
const response = await this.http.get("/content_types", params);
|
|
708
|
+
return { items: response.data.content_types ?? [], count: response.data.count };
|
|
709
|
+
},
|
|
710
|
+
{ limit: opts?.limit }
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
async listAll(opts) {
|
|
714
|
+
return collectAll(this.list(opts));
|
|
715
|
+
}
|
|
716
|
+
async export(uid) {
|
|
717
|
+
const response = await this.http.get(
|
|
718
|
+
`/content_types/${uid}/export`
|
|
719
|
+
);
|
|
720
|
+
return response.data.content_type;
|
|
721
|
+
}
|
|
722
|
+
async import(data) {
|
|
723
|
+
const response = await this.http.post(
|
|
724
|
+
"/content_types/import",
|
|
725
|
+
data
|
|
726
|
+
);
|
|
727
|
+
return response.data.content_type;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// src/cma/entries.ts
|
|
732
|
+
var EntriesClient = class {
|
|
733
|
+
constructor(http) {
|
|
734
|
+
this.http = http;
|
|
735
|
+
}
|
|
736
|
+
basePath(ctUid) {
|
|
737
|
+
return `/content_types/${ctUid}/entries`;
|
|
738
|
+
}
|
|
739
|
+
list(ctUid, opts) {
|
|
740
|
+
return paginate(
|
|
741
|
+
async (skip, limit) => {
|
|
742
|
+
const params = {
|
|
743
|
+
skip: String(skip),
|
|
744
|
+
limit: String(limit)
|
|
745
|
+
};
|
|
746
|
+
if (opts?.locale) params.locale = opts.locale;
|
|
747
|
+
if (opts?.include_publish_details) params.include_publish_details = "true";
|
|
748
|
+
if (opts?.include_workflow) params.include_workflow = "true";
|
|
749
|
+
if (opts?.include_count) params.include_count = "true";
|
|
750
|
+
if (opts?.query) params.query = JSON.stringify(opts.query);
|
|
751
|
+
if (opts?.asc) params.asc = opts.asc;
|
|
752
|
+
if (opts?.desc) params.desc = opts.desc;
|
|
753
|
+
const response = await this.http.get(
|
|
754
|
+
this.basePath(ctUid),
|
|
755
|
+
params
|
|
756
|
+
);
|
|
757
|
+
return { items: response.data.entries ?? [], count: response.data.count };
|
|
758
|
+
},
|
|
759
|
+
{ limit: opts?.limit }
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
async listAll(ctUid, opts) {
|
|
763
|
+
return collectAll(this.list(ctUid, opts));
|
|
764
|
+
}
|
|
765
|
+
async get(ctUid, entryUid, opts) {
|
|
766
|
+
const params = {};
|
|
767
|
+
if (opts?.locale) params.locale = opts.locale;
|
|
768
|
+
if (opts?.include_publish_details) params.include_publish_details = "true";
|
|
769
|
+
if (opts?.include_workflow) params.include_workflow = "true";
|
|
770
|
+
if (opts?.version) params.version = String(opts.version);
|
|
771
|
+
const response = await this.http.get(
|
|
772
|
+
`${this.basePath(ctUid)}/${entryUid}`,
|
|
773
|
+
Object.keys(params).length > 0 ? params : void 0
|
|
774
|
+
);
|
|
775
|
+
return response.data.entry;
|
|
776
|
+
}
|
|
777
|
+
async create(ctUid, data) {
|
|
778
|
+
const response = await this.http.post(this.basePath(ctUid), { entry: data });
|
|
779
|
+
return response.data.entry;
|
|
780
|
+
}
|
|
781
|
+
async update(ctUid, entryUid, data) {
|
|
782
|
+
const response = await this.http.put(`${this.basePath(ctUid)}/${entryUid}`, {
|
|
783
|
+
entry: data
|
|
784
|
+
});
|
|
785
|
+
return response.data.entry;
|
|
786
|
+
}
|
|
787
|
+
async delete(ctUid, entryUid, opts) {
|
|
788
|
+
let path = `${this.basePath(ctUid)}/${entryUid}`;
|
|
789
|
+
if (opts?.locale) path += `?locale=${encodeURIComponent(opts.locale)}`;
|
|
790
|
+
await this.http.delete(path);
|
|
791
|
+
}
|
|
792
|
+
async publish(ctUid, entryUid, data) {
|
|
793
|
+
await this.http.post(`${this.basePath(ctUid)}/${entryUid}/publish`, { entry: data });
|
|
794
|
+
}
|
|
795
|
+
async unpublish(ctUid, entryUid, data) {
|
|
796
|
+
await this.http.post(`${this.basePath(ctUid)}/${entryUid}/unpublish`, { entry: data });
|
|
797
|
+
}
|
|
798
|
+
async localize(ctUid, entryUid, data) {
|
|
799
|
+
const response = await this.http.post(
|
|
800
|
+
`${this.basePath(ctUid)}/${entryUid}/localize`,
|
|
801
|
+
{ entry: data }
|
|
802
|
+
);
|
|
803
|
+
return response.data.entry;
|
|
804
|
+
}
|
|
805
|
+
async setWorkflowStage(ctUid, entryUid, data) {
|
|
806
|
+
await this.http.post(`${this.basePath(ctUid)}/${entryUid}/workflow`, data);
|
|
807
|
+
}
|
|
808
|
+
async references(ctUid, entryUid) {
|
|
809
|
+
const response = await this.http.get(
|
|
810
|
+
`${this.basePath(ctUid)}/${entryUid}/references`
|
|
811
|
+
);
|
|
812
|
+
return response.data.references ?? [];
|
|
813
|
+
}
|
|
814
|
+
async languages(ctUid, entryUid) {
|
|
815
|
+
const response = await this.http.get(
|
|
816
|
+
`${this.basePath(ctUid)}/${entryUid}/languages`
|
|
817
|
+
);
|
|
818
|
+
return response.data.locales ?? [];
|
|
819
|
+
}
|
|
820
|
+
async versions(ctUid, entryUid) {
|
|
821
|
+
const response = await this.http.get(
|
|
822
|
+
`${this.basePath(ctUid)}/${entryUid}/versions`
|
|
823
|
+
);
|
|
824
|
+
return response.data.versions ?? [];
|
|
825
|
+
}
|
|
826
|
+
async import(ctUid, data, opts) {
|
|
827
|
+
let path = `${this.basePath(ctUid)}/import`;
|
|
828
|
+
const params = [];
|
|
829
|
+
if (opts?.locale) params.push(`locale=${encodeURIComponent(opts.locale)}`);
|
|
830
|
+
if (opts?.overwrite) params.push("overwrite=true");
|
|
831
|
+
if (params.length > 0) path += `?${params.join("&")}`;
|
|
832
|
+
const response = await this.http.post(path, data);
|
|
833
|
+
return response.data.entry;
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
// src/cma/environments.ts
|
|
838
|
+
var EnvironmentsClient = class extends CrudClient {
|
|
839
|
+
constructor(http) {
|
|
840
|
+
super(http, {
|
|
841
|
+
basePath: "/environments",
|
|
842
|
+
singularKey: "environment",
|
|
843
|
+
pluralKey: "environments"
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// src/cma/extensions.ts
|
|
849
|
+
var ExtensionsClient = class extends CrudClient {
|
|
850
|
+
constructor(http) {
|
|
851
|
+
super(http, { basePath: "/extensions", singularKey: "extension", pluralKey: "extensions" });
|
|
852
|
+
}
|
|
853
|
+
async upload(form) {
|
|
854
|
+
const response = await this.http.upload("/extensions", form);
|
|
855
|
+
return response.data.extension;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
// src/cma/global-fields.ts
|
|
860
|
+
var GlobalFieldsClient = class extends CrudClient {
|
|
861
|
+
constructor(http) {
|
|
862
|
+
super(http, {
|
|
863
|
+
basePath: "/global_fields",
|
|
864
|
+
singularKey: "global_field",
|
|
865
|
+
pluralKey: "global_fields"
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
async export(uid) {
|
|
869
|
+
const response = await this.http.get(
|
|
870
|
+
`/global_fields/${uid}/export`
|
|
871
|
+
);
|
|
872
|
+
return response.data.global_field;
|
|
873
|
+
}
|
|
874
|
+
async import(data) {
|
|
875
|
+
const response = await this.http.post(
|
|
876
|
+
"/global_fields/import",
|
|
877
|
+
data
|
|
878
|
+
);
|
|
879
|
+
return response.data.global_field;
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/cma/labels.ts
|
|
884
|
+
var LabelsClient = class extends CrudClient {
|
|
885
|
+
constructor(http) {
|
|
886
|
+
super(http, { basePath: "/labels", singularKey: "label", pluralKey: "labels" });
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
// src/cma/locales.ts
|
|
891
|
+
var LocalesClient = class extends CrudClient {
|
|
892
|
+
constructor(http) {
|
|
893
|
+
super(http, { basePath: "/locales", singularKey: "locale", pluralKey: "locales" });
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// src/cma/publish-rules.ts
|
|
898
|
+
var PublishRulesClient = class extends CrudClient {
|
|
899
|
+
constructor(http) {
|
|
900
|
+
super(http, {
|
|
901
|
+
basePath: "/workflows/publishing_rules",
|
|
902
|
+
singularKey: "publishing_rule",
|
|
903
|
+
pluralKey: "publishing_rules"
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
// src/cma/releases.ts
|
|
909
|
+
var ReleasesClient = class {
|
|
910
|
+
constructor(http) {
|
|
911
|
+
this.http = http;
|
|
912
|
+
}
|
|
913
|
+
list(opts) {
|
|
914
|
+
return paginate(
|
|
915
|
+
async (skip, limit) => {
|
|
916
|
+
const params = {
|
|
917
|
+
skip: String(skip),
|
|
918
|
+
limit: String(limit)
|
|
919
|
+
};
|
|
920
|
+
if (opts?.include_count) params.include_count = "true";
|
|
921
|
+
const response = await this.http.get(
|
|
922
|
+
"/releases",
|
|
923
|
+
params
|
|
924
|
+
);
|
|
925
|
+
return { items: response.data.releases ?? [], count: response.data.count };
|
|
926
|
+
},
|
|
927
|
+
{ limit: opts?.limit }
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
async listAll(opts) {
|
|
931
|
+
return collectAll(this.list(opts));
|
|
932
|
+
}
|
|
933
|
+
async get(uid) {
|
|
934
|
+
const response = await this.http.get(`/releases/${uid}`);
|
|
935
|
+
return response.data.release;
|
|
936
|
+
}
|
|
937
|
+
async create(data) {
|
|
938
|
+
const response = await this.http.post("/releases", { release: data });
|
|
939
|
+
return response.data.release;
|
|
940
|
+
}
|
|
941
|
+
async update(uid, data) {
|
|
942
|
+
const response = await this.http.put(`/releases/${uid}`, {
|
|
943
|
+
release: data
|
|
944
|
+
});
|
|
945
|
+
return response.data.release;
|
|
946
|
+
}
|
|
947
|
+
async delete(uid) {
|
|
948
|
+
await this.http.delete(`/releases/${uid}`);
|
|
949
|
+
}
|
|
950
|
+
async deploy(uid, data) {
|
|
951
|
+
await this.http.post(`/releases/${uid}/deploy`, { release: data });
|
|
952
|
+
}
|
|
953
|
+
// ─── Items ──────────────────────────────────────────────────────
|
|
954
|
+
async listItems(uid) {
|
|
955
|
+
const response = await this.http.get(`/releases/${uid}/items`);
|
|
956
|
+
return response.data.items ?? [];
|
|
957
|
+
}
|
|
958
|
+
async addItem(uid, item) {
|
|
959
|
+
await this.http.post(`/releases/${uid}/items`, { item });
|
|
960
|
+
}
|
|
961
|
+
async removeItem(uid, item) {
|
|
962
|
+
await this.http.post(`/releases/${uid}/items/delete`, { item });
|
|
963
|
+
}
|
|
964
|
+
async clone(uid, data) {
|
|
965
|
+
const response = await this.http.post(`/releases/${uid}/clone`, {
|
|
966
|
+
release: data
|
|
967
|
+
});
|
|
968
|
+
return response.data.release;
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// src/cma/roles.ts
|
|
973
|
+
var RolesClient = class extends CrudClient {
|
|
974
|
+
constructor(http) {
|
|
975
|
+
super(http, { basePath: "/roles", singularKey: "role", pluralKey: "roles" });
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
// src/cma/taxonomies.ts
|
|
980
|
+
var TaxonomiesClient = class {
|
|
981
|
+
constructor(http) {
|
|
982
|
+
this.http = http;
|
|
983
|
+
}
|
|
984
|
+
// ─── Taxonomies ───────────────────────────────────────────────────
|
|
985
|
+
list(opts) {
|
|
986
|
+
return paginate(
|
|
987
|
+
async (skip, limit) => {
|
|
988
|
+
const response = await this.http.get(
|
|
989
|
+
"/taxonomies",
|
|
990
|
+
{ skip: String(skip), limit: String(limit) }
|
|
991
|
+
);
|
|
992
|
+
return { items: response.data.taxonomies ?? [], count: response.data.count };
|
|
993
|
+
},
|
|
994
|
+
{ limit: opts?.limit }
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
async listAll(opts) {
|
|
998
|
+
return collectAll(this.list(opts));
|
|
999
|
+
}
|
|
1000
|
+
async get(uid) {
|
|
1001
|
+
const response = await this.http.get(`/taxonomies/${uid}`);
|
|
1002
|
+
return response.data.taxonomy;
|
|
1003
|
+
}
|
|
1004
|
+
async create(data) {
|
|
1005
|
+
const response = await this.http.post("/taxonomies", {
|
|
1006
|
+
taxonomy: data
|
|
1007
|
+
});
|
|
1008
|
+
return response.data.taxonomy;
|
|
1009
|
+
}
|
|
1010
|
+
async update(uid, data) {
|
|
1011
|
+
const response = await this.http.put(`/taxonomies/${uid}`, {
|
|
1012
|
+
taxonomy: data
|
|
1013
|
+
});
|
|
1014
|
+
return response.data.taxonomy;
|
|
1015
|
+
}
|
|
1016
|
+
async delete(uid) {
|
|
1017
|
+
await this.http.delete(`/taxonomies/${uid}`);
|
|
1018
|
+
}
|
|
1019
|
+
// ─── Terms ────────────────────────────────────────────────────────
|
|
1020
|
+
listTerms(taxonomyUid, opts) {
|
|
1021
|
+
return paginate(
|
|
1022
|
+
async (skip, limit) => {
|
|
1023
|
+
const response = await this.http.get(
|
|
1024
|
+
`/taxonomies/${taxonomyUid}/terms`,
|
|
1025
|
+
{ skip: String(skip), limit: String(limit) }
|
|
1026
|
+
);
|
|
1027
|
+
return { items: response.data.terms ?? [], count: response.data.count };
|
|
1028
|
+
},
|
|
1029
|
+
{ limit: opts?.limit }
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
async listAllTerms(taxonomyUid, opts) {
|
|
1033
|
+
return collectAll(this.listTerms(taxonomyUid, opts));
|
|
1034
|
+
}
|
|
1035
|
+
async getTerm(taxonomyUid, termUid) {
|
|
1036
|
+
const response = await this.http.get(
|
|
1037
|
+
`/taxonomies/${taxonomyUid}/terms/${termUid}`
|
|
1038
|
+
);
|
|
1039
|
+
return response.data.term;
|
|
1040
|
+
}
|
|
1041
|
+
async createTerm(taxonomyUid, data) {
|
|
1042
|
+
const response = await this.http.post(
|
|
1043
|
+
`/taxonomies/${taxonomyUid}/terms`,
|
|
1044
|
+
{ term: data }
|
|
1045
|
+
);
|
|
1046
|
+
return response.data.term;
|
|
1047
|
+
}
|
|
1048
|
+
async updateTerm(taxonomyUid, termUid, data) {
|
|
1049
|
+
const response = await this.http.put(
|
|
1050
|
+
`/taxonomies/${taxonomyUid}/terms/${termUid}`,
|
|
1051
|
+
{ term: data }
|
|
1052
|
+
);
|
|
1053
|
+
return response.data.term;
|
|
1054
|
+
}
|
|
1055
|
+
async deleteTerm(taxonomyUid, termUid) {
|
|
1056
|
+
await this.http.delete(`/taxonomies/${taxonomyUid}/terms/${termUid}`);
|
|
1057
|
+
}
|
|
1058
|
+
async ancestors(taxonomyUid, termUid) {
|
|
1059
|
+
const response = await this.http.get(
|
|
1060
|
+
`/taxonomies/${taxonomyUid}/terms/${termUid}/ancestors`
|
|
1061
|
+
);
|
|
1062
|
+
return response.data.terms ?? [];
|
|
1063
|
+
}
|
|
1064
|
+
async descendants(taxonomyUid, termUid) {
|
|
1065
|
+
const response = await this.http.get(
|
|
1066
|
+
`/taxonomies/${taxonomyUid}/terms/${termUid}/descendants`
|
|
1067
|
+
);
|
|
1068
|
+
return response.data.terms ?? [];
|
|
1069
|
+
}
|
|
1070
|
+
async moveTerm(taxonomyUid, termUid, data) {
|
|
1071
|
+
const response = await this.http.put(
|
|
1072
|
+
`/taxonomies/${taxonomyUid}/terms/${termUid}/move`,
|
|
1073
|
+
{ term: data }
|
|
1074
|
+
);
|
|
1075
|
+
return response.data.term;
|
|
1076
|
+
}
|
|
1077
|
+
// ─── Import / Export ──────────────────────────────────────────────
|
|
1078
|
+
async export(uid) {
|
|
1079
|
+
const response = await this.http.get(`/taxonomies/${uid}/export`);
|
|
1080
|
+
return response.data.taxonomy;
|
|
1081
|
+
}
|
|
1082
|
+
async import(data) {
|
|
1083
|
+
const response = await this.http.post("/taxonomies/import", data);
|
|
1084
|
+
return response.data.taxonomy;
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// src/cma/tokens.ts
|
|
1089
|
+
function tokenCrud(http, basePath) {
|
|
1090
|
+
return {
|
|
1091
|
+
async list() {
|
|
1092
|
+
const response = await http.get(basePath);
|
|
1093
|
+
return response.data.tokens ?? [];
|
|
1094
|
+
},
|
|
1095
|
+
async get(uid) {
|
|
1096
|
+
const response = await http.get(`${basePath}/${uid}`);
|
|
1097
|
+
return response.data.token;
|
|
1098
|
+
},
|
|
1099
|
+
async create(data) {
|
|
1100
|
+
const response = await http.post(basePath, { token: data });
|
|
1101
|
+
return response.data.token;
|
|
1102
|
+
},
|
|
1103
|
+
async update(uid, data) {
|
|
1104
|
+
const response = await http.put(`${basePath}/${uid}`, { token: data });
|
|
1105
|
+
return response.data.token;
|
|
1106
|
+
},
|
|
1107
|
+
async delete(uid) {
|
|
1108
|
+
await http.delete(`${basePath}/${uid}`);
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
var TokensClient = class {
|
|
1113
|
+
management;
|
|
1114
|
+
delivery;
|
|
1115
|
+
preview;
|
|
1116
|
+
constructor(http) {
|
|
1117
|
+
this.management = tokenCrud(http, "/stacks/management_tokens");
|
|
1118
|
+
this.delivery = tokenCrud(http, "/stacks/delivery_tokens");
|
|
1119
|
+
this.preview = tokenCrud(http, "/stacks/preview_tokens");
|
|
1120
|
+
}
|
|
1121
|
+
// ─── Management Tokens ────────────────────────────────────────────
|
|
1122
|
+
listManagementTokens() {
|
|
1123
|
+
return this.management.list();
|
|
1124
|
+
}
|
|
1125
|
+
getManagementToken(uid) {
|
|
1126
|
+
return this.management.get(uid);
|
|
1127
|
+
}
|
|
1128
|
+
createManagementToken(data) {
|
|
1129
|
+
return this.management.create(data);
|
|
1130
|
+
}
|
|
1131
|
+
updateManagementToken(uid, data) {
|
|
1132
|
+
return this.management.update(uid, data);
|
|
1133
|
+
}
|
|
1134
|
+
deleteManagementToken(uid) {
|
|
1135
|
+
return this.management.delete(uid);
|
|
1136
|
+
}
|
|
1137
|
+
// ─── Delivery Tokens ──────────────────────────────────────────────
|
|
1138
|
+
listDeliveryTokens() {
|
|
1139
|
+
return this.delivery.list();
|
|
1140
|
+
}
|
|
1141
|
+
getDeliveryToken(uid) {
|
|
1142
|
+
return this.delivery.get(uid);
|
|
1143
|
+
}
|
|
1144
|
+
createDeliveryToken(data) {
|
|
1145
|
+
return this.delivery.create(data);
|
|
1146
|
+
}
|
|
1147
|
+
updateDeliveryToken(uid, data) {
|
|
1148
|
+
return this.delivery.update(uid, data);
|
|
1149
|
+
}
|
|
1150
|
+
deleteDeliveryToken(uid) {
|
|
1151
|
+
return this.delivery.delete(uid);
|
|
1152
|
+
}
|
|
1153
|
+
// ─── Preview Tokens ──────────────────────────────────────────────
|
|
1154
|
+
listPreviewTokens() {
|
|
1155
|
+
return this.preview.list();
|
|
1156
|
+
}
|
|
1157
|
+
getPreviewToken(uid) {
|
|
1158
|
+
return this.preview.get(uid);
|
|
1159
|
+
}
|
|
1160
|
+
createPreviewToken(data) {
|
|
1161
|
+
return this.preview.create(data);
|
|
1162
|
+
}
|
|
1163
|
+
updatePreviewToken(uid, data) {
|
|
1164
|
+
return this.preview.update(uid, data);
|
|
1165
|
+
}
|
|
1166
|
+
deletePreviewToken(uid) {
|
|
1167
|
+
return this.preview.delete(uid);
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
// src/cma/webhooks.ts
|
|
1172
|
+
var WebhooksClient = class extends CrudClient {
|
|
1173
|
+
constructor(http) {
|
|
1174
|
+
super(http, { basePath: "/webhooks", singularKey: "webhook", pluralKey: "webhooks" });
|
|
1175
|
+
}
|
|
1176
|
+
async logs(uid) {
|
|
1177
|
+
const response = await this.http.get(`/webhooks/${uid}/logs`);
|
|
1178
|
+
return response.data.logs ?? [];
|
|
1179
|
+
}
|
|
1180
|
+
async retry(uid, executionUid) {
|
|
1181
|
+
await this.http.post(`/webhooks/${uid}/retry/${executionUid}`, {});
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
// src/cma/workflows.ts
|
|
1186
|
+
var WorkflowsClient = class extends CrudClient {
|
|
1187
|
+
constructor(http) {
|
|
1188
|
+
super(http, { basePath: "/workflows", singularKey: "workflow", pluralKey: "workflows" });
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/cma/client.ts
|
|
1193
|
+
function createCMAClient(config) {
|
|
1194
|
+
const endpoints = resolveEndpoints(config.region);
|
|
1195
|
+
const headers = { api_key: config.apiKey };
|
|
1196
|
+
switch (config.auth.type) {
|
|
1197
|
+
case "management-token":
|
|
1198
|
+
headers.authorization = config.auth.token;
|
|
1199
|
+
break;
|
|
1200
|
+
case "oauth":
|
|
1201
|
+
headers.authorization = `Bearer ${config.auth.accessToken}`;
|
|
1202
|
+
break;
|
|
1203
|
+
case "authtoken":
|
|
1204
|
+
headers.authtoken = config.auth.token;
|
|
1205
|
+
break;
|
|
1206
|
+
}
|
|
1207
|
+
if (config.branch) {
|
|
1208
|
+
headers.branch = config.branch;
|
|
1209
|
+
}
|
|
1210
|
+
const http = new ContentstackHttpClient({
|
|
1211
|
+
...config.httpOptions,
|
|
1212
|
+
baseUrl: config.httpOptions?.baseUrl ?? `${endpoints.cma}/v3`,
|
|
1213
|
+
headers: {
|
|
1214
|
+
...config.httpOptions?.headers,
|
|
1215
|
+
...headers
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
return {
|
|
1219
|
+
entries: new EntriesClient(http),
|
|
1220
|
+
contentTypes: new ContentTypesClient(http),
|
|
1221
|
+
assets: new AssetsClient(http),
|
|
1222
|
+
environments: new EnvironmentsClient(http),
|
|
1223
|
+
locales: new LocalesClient(http),
|
|
1224
|
+
globalFields: new GlobalFieldsClient(http),
|
|
1225
|
+
webhooks: new WebhooksClient(http),
|
|
1226
|
+
workflows: new WorkflowsClient(http),
|
|
1227
|
+
releases: new ReleasesClient(http),
|
|
1228
|
+
branches: new BranchesClient(http),
|
|
1229
|
+
branchAliases: new BranchAliasesClient(http),
|
|
1230
|
+
taxonomies: new TaxonomiesClient(http),
|
|
1231
|
+
bulk: new BulkOperationsClient(http),
|
|
1232
|
+
tokens: new TokensClient(http),
|
|
1233
|
+
labels: new LabelsClient(http),
|
|
1234
|
+
roles: new RolesClient(http),
|
|
1235
|
+
auditLog: new AuditLogClient(http),
|
|
1236
|
+
extensions: new ExtensionsClient(http),
|
|
1237
|
+
publishRules: new PublishRulesClient(http),
|
|
1238
|
+
onBranch(branchUid) {
|
|
1239
|
+
return createCMAClient({ ...config, branch: branchUid });
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// src/cma/request-builders.ts
|
|
1245
|
+
function nonEmptyParams(params) {
|
|
1246
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
1247
|
+
}
|
|
1248
|
+
function buildEntryParams(options) {
|
|
1249
|
+
if (!options) return void 0;
|
|
1250
|
+
const params = {};
|
|
1251
|
+
if (options.locale) params.locale = options.locale;
|
|
1252
|
+
if (options.version !== void 0) params.version = String(options.version);
|
|
1253
|
+
if (options.includePublishDetails) params.include_publish_details = "true";
|
|
1254
|
+
return nonEmptyParams(params);
|
|
1255
|
+
}
|
|
1256
|
+
function buildEntriesParams(options) {
|
|
1257
|
+
if (!options) return void 0;
|
|
1258
|
+
const params = {};
|
|
1259
|
+
if (options.locale) params.locale = options.locale;
|
|
1260
|
+
if (options.limit !== void 0) params.limit = String(options.limit);
|
|
1261
|
+
if (options.skip !== void 0) params.skip = String(options.skip);
|
|
1262
|
+
if (options.includePublishDetails) params.include_publish_details = "true";
|
|
1263
|
+
if (options.query) params.query = JSON.stringify(options.query);
|
|
1264
|
+
return nonEmptyParams(params);
|
|
1265
|
+
}
|
|
1266
|
+
function buildAssetsParams(options) {
|
|
1267
|
+
if (!options) return void 0;
|
|
1268
|
+
const params = {};
|
|
1269
|
+
if (options.folder) params.folder = options.folder;
|
|
1270
|
+
if (options.limit !== void 0) params.limit = String(options.limit);
|
|
1271
|
+
if (options.skip !== void 0) params.skip = String(options.skip);
|
|
1272
|
+
return nonEmptyParams(params);
|
|
1273
|
+
}
|
|
1274
|
+
function appendQueryString(path, params) {
|
|
1275
|
+
const query = params.toString();
|
|
1276
|
+
return query ? `${path}?${query}` : path;
|
|
1277
|
+
}
|
|
1278
|
+
function buildCreateEntryRequest(vars) {
|
|
1279
|
+
const params = new URLSearchParams();
|
|
1280
|
+
if (vars.locale) params.set("locale", vars.locale);
|
|
1281
|
+
return {
|
|
1282
|
+
path: appendQueryString(`/content_types/${vars.contentTypeUid}/entries`, params),
|
|
1283
|
+
body: { entry: vars.entry }
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
function buildUpdateEntryRequest(vars) {
|
|
1287
|
+
const params = new URLSearchParams();
|
|
1288
|
+
if (vars.locale) params.set("locale", vars.locale);
|
|
1289
|
+
return {
|
|
1290
|
+
path: appendQueryString(
|
|
1291
|
+
`/content_types/${vars.contentTypeUid}/entries/${vars.entryUid}`,
|
|
1292
|
+
params
|
|
1293
|
+
),
|
|
1294
|
+
body: { entry: vars.entry }
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function buildDeleteEntryRequest(vars) {
|
|
1298
|
+
const params = new URLSearchParams();
|
|
1299
|
+
if (vars.locale) params.set("locale", vars.locale);
|
|
1300
|
+
if (vars.deleteAllLocalized) params.set("delete_all_localized", "true");
|
|
1301
|
+
return {
|
|
1302
|
+
path: appendQueryString(
|
|
1303
|
+
`/content_types/${vars.contentTypeUid}/entries/${vars.entryUid}`,
|
|
1304
|
+
params
|
|
1305
|
+
)
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
function buildPublishEntryRequest(vars) {
|
|
1309
|
+
return {
|
|
1310
|
+
path: `/content_types/${vars.contentTypeUid}/entries/${vars.entryUid}/publish`,
|
|
1311
|
+
body: {
|
|
1312
|
+
entry: {
|
|
1313
|
+
environments: vars.environments,
|
|
1314
|
+
locales: vars.locales,
|
|
1315
|
+
...vars.scheduledAt ? { scheduled_at: vars.scheduledAt } : {}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// src/launch/response.ts
|
|
1322
|
+
function extractList(body, key) {
|
|
1323
|
+
if (Array.isArray(body)) {
|
|
1324
|
+
return { items: body };
|
|
1325
|
+
}
|
|
1326
|
+
if (body && typeof body === "object") {
|
|
1327
|
+
const obj = body;
|
|
1328
|
+
if (key in obj && Array.isArray(obj[key])) {
|
|
1329
|
+
const pagination = obj.pagination;
|
|
1330
|
+
return { items: obj[key], count: pagination?.count };
|
|
1331
|
+
}
|
|
1332
|
+
if ("data" in obj && Array.isArray(obj.data)) {
|
|
1333
|
+
return { items: obj.data, count: obj.count };
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return { items: [] };
|
|
1337
|
+
}
|
|
1338
|
+
function extractItem(body) {
|
|
1339
|
+
if (body && typeof body === "object" && "data" in body) {
|
|
1340
|
+
return body.data;
|
|
1341
|
+
}
|
|
1342
|
+
return body;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// src/launch/deployments.ts
|
|
1346
|
+
var DeploymentsClient = class {
|
|
1347
|
+
constructor(http) {
|
|
1348
|
+
this.http = http;
|
|
1349
|
+
}
|
|
1350
|
+
basePath(projectUid, environmentUid) {
|
|
1351
|
+
return `/projects/${projectUid}/environments/${environmentUid}/deployments`;
|
|
1352
|
+
}
|
|
1353
|
+
list(projectUid, environmentUid, options) {
|
|
1354
|
+
return paginate(
|
|
1355
|
+
async (skip, limit) => {
|
|
1356
|
+
const params = {
|
|
1357
|
+
skip: String(skip),
|
|
1358
|
+
limit: String(limit)
|
|
1359
|
+
};
|
|
1360
|
+
const response = await this.http.get(
|
|
1361
|
+
this.basePath(projectUid, environmentUid),
|
|
1362
|
+
params
|
|
1363
|
+
);
|
|
1364
|
+
return extractList(response.data, "deployments");
|
|
1365
|
+
},
|
|
1366
|
+
{ limit: options?.limit }
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
async listAll(projectUid, environmentUid, options) {
|
|
1370
|
+
return collectAll(this.list(projectUid, environmentUid, options));
|
|
1371
|
+
}
|
|
1372
|
+
async get(projectUid, environmentUid, deploymentUid) {
|
|
1373
|
+
const response = await this.http.get(
|
|
1374
|
+
`${this.basePath(projectUid, environmentUid)}/${deploymentUid}`
|
|
1375
|
+
);
|
|
1376
|
+
return extractItem(response.data);
|
|
1377
|
+
}
|
|
1378
|
+
async create(projectUid, environmentUid, data) {
|
|
1379
|
+
const response = await this.http.post(this.basePath(projectUid, environmentUid), data);
|
|
1380
|
+
return extractItem(response.data);
|
|
1381
|
+
}
|
|
1382
|
+
async getDeploymentLogs(projectUid, environmentUid, deploymentUid, options) {
|
|
1383
|
+
const params = {};
|
|
1384
|
+
if (options?.timestamp) params.timestamp = options.timestamp;
|
|
1385
|
+
const response = await this.http.get(
|
|
1386
|
+
`${this.basePath(projectUid, environmentUid)}/${deploymentUid}/logs/deployment-logs`,
|
|
1387
|
+
Object.keys(params).length > 0 ? params : void 0
|
|
1388
|
+
);
|
|
1389
|
+
return extractList(response.data, "logs").items;
|
|
1390
|
+
}
|
|
1391
|
+
async getServerLogs(projectUid, environmentUid, deploymentUid, options) {
|
|
1392
|
+
const params = {};
|
|
1393
|
+
if (options?.startTime !== void 0) params.startTime = String(options.startTime);
|
|
1394
|
+
if (options?.endTime !== void 0) params.endTime = String(options.endTime);
|
|
1395
|
+
const response = await this.http.get(
|
|
1396
|
+
`${this.basePath(projectUid, environmentUid)}/${deploymentUid}/logs/server-logs`,
|
|
1397
|
+
Object.keys(params).length > 0 ? params : void 0
|
|
1398
|
+
);
|
|
1399
|
+
return extractList(response.data, "logs").items;
|
|
1400
|
+
}
|
|
1401
|
+
async getUploadUrl(projectUid, environmentUid) {
|
|
1402
|
+
const response = await this.http.get(
|
|
1403
|
+
`${this.basePath(projectUid, environmentUid)}/upload/signed_url`
|
|
1404
|
+
);
|
|
1405
|
+
return extractItem(response.data);
|
|
1406
|
+
}
|
|
1407
|
+
async getDownloadUrl(projectUid, environmentUid, deploymentUid) {
|
|
1408
|
+
const response = await this.http.get(
|
|
1409
|
+
`${this.basePath(projectUid, environmentUid)}/${deploymentUid}/download/signed_url`
|
|
1410
|
+
);
|
|
1411
|
+
const item = extractItem(response.data);
|
|
1412
|
+
return item.downloadUrl;
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
// src/launch/environments.ts
|
|
1417
|
+
var EnvironmentsClient2 = class {
|
|
1418
|
+
constructor(http) {
|
|
1419
|
+
this.http = http;
|
|
1420
|
+
}
|
|
1421
|
+
list(projectUid) {
|
|
1422
|
+
return paginate(async (skip, limit) => {
|
|
1423
|
+
const response = await this.http.get(`/projects/${projectUid}/environments`, {
|
|
1424
|
+
skip: String(skip),
|
|
1425
|
+
limit: String(limit)
|
|
1426
|
+
});
|
|
1427
|
+
return extractList(response.data, "environments");
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
async listAll(projectUid) {
|
|
1431
|
+
return collectAll(this.list(projectUid));
|
|
1432
|
+
}
|
|
1433
|
+
async get(projectUid, envUid) {
|
|
1434
|
+
const response = await this.http.get(`/projects/${projectUid}/environments/${envUid}`);
|
|
1435
|
+
return extractItem(response.data);
|
|
1436
|
+
}
|
|
1437
|
+
async create(projectUid, data) {
|
|
1438
|
+
const response = await this.http.post(`/projects/${projectUid}/environments`, data);
|
|
1439
|
+
return extractItem(response.data);
|
|
1440
|
+
}
|
|
1441
|
+
async update(projectUid, envUid, data) {
|
|
1442
|
+
const response = await this.http.put(
|
|
1443
|
+
`/projects/${projectUid}/environments/${envUid}`,
|
|
1444
|
+
data
|
|
1445
|
+
);
|
|
1446
|
+
return extractItem(response.data);
|
|
1447
|
+
}
|
|
1448
|
+
async delete(projectUid, envUid) {
|
|
1449
|
+
await this.http.delete(`/projects/${projectUid}/environments/${envUid}`);
|
|
1450
|
+
}
|
|
1451
|
+
async revalidateCDNCache(projectUid, envUid, data) {
|
|
1452
|
+
await this.http.post(
|
|
1453
|
+
`/projects/${projectUid}/environments/${envUid}/revalidate-cdn-cache`,
|
|
1454
|
+
data
|
|
1455
|
+
);
|
|
1456
|
+
}
|
|
1457
|
+
async getUploadUrl(projectUid) {
|
|
1458
|
+
const response = await this.http.get(
|
|
1459
|
+
`/projects/${projectUid}/environments/upload/signed_url`
|
|
1460
|
+
);
|
|
1461
|
+
return extractItem(response.data);
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1465
|
+
// src/launch/projects.ts
|
|
1466
|
+
var ProjectsClient = class {
|
|
1467
|
+
constructor(http) {
|
|
1468
|
+
this.http = http;
|
|
1469
|
+
}
|
|
1470
|
+
list(options) {
|
|
1471
|
+
return paginate(
|
|
1472
|
+
async (skip, limit) => {
|
|
1473
|
+
const response = await this.http.get("/projects", {
|
|
1474
|
+
skip: String(skip),
|
|
1475
|
+
limit: String(limit)
|
|
1476
|
+
});
|
|
1477
|
+
return extractList(response.data, "projects");
|
|
1478
|
+
},
|
|
1479
|
+
{ limit: options?.limit }
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
async listAll(options) {
|
|
1483
|
+
return collectAll(this.list(options));
|
|
1484
|
+
}
|
|
1485
|
+
async get(projectUid) {
|
|
1486
|
+
const response = await this.http.get(`/projects/${projectUid}`);
|
|
1487
|
+
return extractItem(response.data);
|
|
1488
|
+
}
|
|
1489
|
+
async create(data) {
|
|
1490
|
+
const response = await this.http.post("/projects", data);
|
|
1491
|
+
return extractItem(response.data);
|
|
1492
|
+
}
|
|
1493
|
+
async update(projectUid, data) {
|
|
1494
|
+
const response = await this.http.put(`/projects/${projectUid}`, data);
|
|
1495
|
+
return extractItem(response.data);
|
|
1496
|
+
}
|
|
1497
|
+
async delete(projectUid) {
|
|
1498
|
+
await this.http.delete(`/projects/${projectUid}`);
|
|
1499
|
+
}
|
|
1500
|
+
async transferGitRepository(projectUid, data) {
|
|
1501
|
+
await this.http.patch(`/projects/${projectUid}/git-repository`, data);
|
|
1502
|
+
}
|
|
1503
|
+
async getUploadUrl() {
|
|
1504
|
+
const response = await this.http.get("/projects/upload/signed_url");
|
|
1505
|
+
return extractItem(response.data);
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
// src/launch/client.ts
|
|
1510
|
+
function createLaunchClient(config) {
|
|
1511
|
+
const endpoints = resolveEndpoints(config.region);
|
|
1512
|
+
const headers = {
|
|
1513
|
+
organization_uid: config.organizationUid
|
|
1514
|
+
};
|
|
1515
|
+
switch (config.auth.type) {
|
|
1516
|
+
case "oauth":
|
|
1517
|
+
headers.authorization = `Bearer ${config.auth.accessToken}`;
|
|
1518
|
+
break;
|
|
1519
|
+
case "authtoken":
|
|
1520
|
+
headers.authtoken = config.auth.token;
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
const http = new ContentstackHttpClient({
|
|
1524
|
+
...config.httpOptions,
|
|
1525
|
+
baseUrl: config.httpOptions?.baseUrl ?? endpoints.launch,
|
|
1526
|
+
headers: {
|
|
1527
|
+
...config.httpOptions?.headers,
|
|
1528
|
+
...headers
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
return {
|
|
1532
|
+
projects: new ProjectsClient(http),
|
|
1533
|
+
environments: new EnvironmentsClient2(http),
|
|
1534
|
+
deployments: new DeploymentsClient(http)
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
// src/brandkit/brand-kits.ts
|
|
1539
|
+
var BrandKitsSubClient = class {
|
|
1540
|
+
constructor(http) {
|
|
1541
|
+
this.http = http;
|
|
1542
|
+
}
|
|
1543
|
+
list(options) {
|
|
1544
|
+
return paginate(
|
|
1545
|
+
async (skip, limit) => {
|
|
1546
|
+
const response = await this.http.get(
|
|
1547
|
+
"/v1/brand-kits",
|
|
1548
|
+
{
|
|
1549
|
+
skip: String(skip),
|
|
1550
|
+
limit: String(limit)
|
|
1551
|
+
}
|
|
1552
|
+
);
|
|
1553
|
+
return { items: response.data.data ?? [], count: response.data.count };
|
|
1554
|
+
},
|
|
1555
|
+
{ limit: options?.limit }
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
async listAll(options) {
|
|
1559
|
+
return collectAll(this.list(options));
|
|
1560
|
+
}
|
|
1561
|
+
async get(brandKitUid) {
|
|
1562
|
+
const response = await this.http.get(`/v1/brand-kits/${brandKitUid}`);
|
|
1563
|
+
return response.data.data;
|
|
1564
|
+
}
|
|
1565
|
+
async create(data) {
|
|
1566
|
+
const response = await this.http.post("/v1/brand-kits", data);
|
|
1567
|
+
return response.data.data;
|
|
1568
|
+
}
|
|
1569
|
+
async update(brandKitUid, data) {
|
|
1570
|
+
const response = await this.http.put(`/v1/brand-kits/${brandKitUid}`, data);
|
|
1571
|
+
return response.data.data;
|
|
1572
|
+
}
|
|
1573
|
+
async delete(brandKitUid) {
|
|
1574
|
+
await this.http.delete(`/v1/brand-kits/${brandKitUid}`);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
// src/brandkit/voice-profiles.ts
|
|
1579
|
+
var VoiceProfilesSubClient = class {
|
|
1580
|
+
constructor(http) {
|
|
1581
|
+
this.http = http;
|
|
1582
|
+
}
|
|
1583
|
+
list(brandKitUid, options) {
|
|
1584
|
+
const scoped = this.http.withHeaders({ brand_kit_uid: brandKitUid });
|
|
1585
|
+
return paginate(
|
|
1586
|
+
async (skip, limit) => {
|
|
1587
|
+
const response = await scoped.get(
|
|
1588
|
+
`/v1/brand-kits/${brandKitUid}/voice-profiles`,
|
|
1589
|
+
{ skip: String(skip), limit: String(limit) }
|
|
1590
|
+
);
|
|
1591
|
+
return { items: response.data.data ?? [], count: response.data.count };
|
|
1592
|
+
},
|
|
1593
|
+
{ limit: options?.limit }
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
async listAll(brandKitUid, options) {
|
|
1597
|
+
return collectAll(this.list(brandKitUid, options));
|
|
1598
|
+
}
|
|
1599
|
+
async get(brandKitUid, voiceProfileUid) {
|
|
1600
|
+
const scoped = this.http.withHeaders({ brand_kit_uid: brandKitUid });
|
|
1601
|
+
const response = await scoped.get(
|
|
1602
|
+
`/v1/brand-kits/${brandKitUid}/voice-profiles/${voiceProfileUid}`
|
|
1603
|
+
);
|
|
1604
|
+
return response.data.data;
|
|
1605
|
+
}
|
|
1606
|
+
async create(brandKitUid, data) {
|
|
1607
|
+
const scoped = this.http.withHeaders({ brand_kit_uid: brandKitUid });
|
|
1608
|
+
const response = await scoped.post(
|
|
1609
|
+
`/v1/brand-kits/${brandKitUid}/voice-profiles`,
|
|
1610
|
+
data
|
|
1611
|
+
);
|
|
1612
|
+
return response.data.data;
|
|
1613
|
+
}
|
|
1614
|
+
async update(brandKitUid, voiceProfileUid, data) {
|
|
1615
|
+
const scoped = this.http.withHeaders({ brand_kit_uid: brandKitUid });
|
|
1616
|
+
const response = await scoped.put(
|
|
1617
|
+
`/v1/brand-kits/${brandKitUid}/voice-profiles/${voiceProfileUid}`,
|
|
1618
|
+
data
|
|
1619
|
+
);
|
|
1620
|
+
return response.data.data;
|
|
1621
|
+
}
|
|
1622
|
+
async delete(brandKitUid, voiceProfileUid) {
|
|
1623
|
+
const scoped = this.http.withHeaders({ brand_kit_uid: brandKitUid });
|
|
1624
|
+
await scoped.delete(`/v1/brand-kits/${brandKitUid}/voice-profiles/${voiceProfileUid}`);
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
// src/brandkit/client.ts
|
|
1629
|
+
function createBrandKitClient(config) {
|
|
1630
|
+
const endpoints = resolveEndpoints(config.region);
|
|
1631
|
+
const headers = {
|
|
1632
|
+
organization_uid: config.organizationUid
|
|
1633
|
+
};
|
|
1634
|
+
switch (config.auth.type) {
|
|
1635
|
+
case "oauth":
|
|
1636
|
+
headers.authorization = `Bearer ${config.auth.accessToken}`;
|
|
1637
|
+
break;
|
|
1638
|
+
case "authtoken":
|
|
1639
|
+
headers.authtoken = config.auth.token;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
const http = new ContentstackHttpClient({
|
|
1643
|
+
...config.httpOptions,
|
|
1644
|
+
baseUrl: config.httpOptions?.baseUrl ?? endpoints.brandKit,
|
|
1645
|
+
headers: {
|
|
1646
|
+
...config.httpOptions?.headers,
|
|
1647
|
+
...headers
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
return {
|
|
1651
|
+
brandKits: new BrandKitsSubClient(http),
|
|
1652
|
+
voiceProfiles: new VoiceProfilesSubClient(http)
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
// src/knowledge-vault/items.ts
|
|
1657
|
+
var KnowledgeVaultItemsClient = class {
|
|
1658
|
+
constructor(http) {
|
|
1659
|
+
this.http = http;
|
|
1660
|
+
}
|
|
1661
|
+
async ingest(data) {
|
|
1662
|
+
const response = await this.http.post("/v1/knowledge-vault", data);
|
|
1663
|
+
return response.data.data;
|
|
1664
|
+
}
|
|
1665
|
+
async update(itemUid, data) {
|
|
1666
|
+
const response = await this.http.put(
|
|
1667
|
+
`/v1/knowledge-vault/${itemUid}`,
|
|
1668
|
+
data
|
|
1669
|
+
);
|
|
1670
|
+
return response.data.data;
|
|
1671
|
+
}
|
|
1672
|
+
async delete(itemUid) {
|
|
1673
|
+
await this.http.delete(`/v1/knowledge-vault/${itemUid}`);
|
|
1674
|
+
}
|
|
1675
|
+
async getUsage() {
|
|
1676
|
+
const response = await this.http.get("/v1/knowledge-vault/usage");
|
|
1677
|
+
return response.data.data;
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
// src/knowledge-vault/client.ts
|
|
1682
|
+
function createKnowledgeVaultClient(config) {
|
|
1683
|
+
const endpoints = resolveEndpoints(config.region);
|
|
1684
|
+
const headers = {
|
|
1685
|
+
organization_uid: config.organizationUid,
|
|
1686
|
+
brand_kit_uid: config.brandKitUid
|
|
1687
|
+
};
|
|
1688
|
+
switch (config.auth.type) {
|
|
1689
|
+
case "oauth":
|
|
1690
|
+
headers.authorization = `Bearer ${config.auth.accessToken}`;
|
|
1691
|
+
break;
|
|
1692
|
+
case "authtoken":
|
|
1693
|
+
headers.authtoken = config.auth.token;
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
const http = new ContentstackHttpClient({
|
|
1697
|
+
...config.httpOptions,
|
|
1698
|
+
baseUrl: config.httpOptions?.baseUrl ?? endpoints.brandKitAI,
|
|
1699
|
+
headers: {
|
|
1700
|
+
...config.httpOptions?.headers,
|
|
1701
|
+
...headers
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
return {
|
|
1705
|
+
items: new KnowledgeVaultItemsClient(http)
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
// src/generative-ai/client.ts
|
|
1710
|
+
function createGenerativeAIClient(config) {
|
|
1711
|
+
const endpoints = resolveEndpoints(config.region);
|
|
1712
|
+
const headers = {
|
|
1713
|
+
organization_uid: config.organizationUid,
|
|
1714
|
+
brand_kit_uid: config.brandKitUid
|
|
1715
|
+
};
|
|
1716
|
+
switch (config.auth.type) {
|
|
1717
|
+
case "oauth":
|
|
1718
|
+
headers.authorization = `Bearer ${config.auth.accessToken}`;
|
|
1719
|
+
break;
|
|
1720
|
+
case "authtoken":
|
|
1721
|
+
headers.authtoken = config.auth.token;
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
const http = new ContentstackHttpClient({
|
|
1725
|
+
...config.httpOptions,
|
|
1726
|
+
baseUrl: config.httpOptions?.baseUrl ?? endpoints.brandKitAI,
|
|
1727
|
+
headers: {
|
|
1728
|
+
...config.httpOptions?.headers,
|
|
1729
|
+
...headers
|
|
1730
|
+
}
|
|
1731
|
+
});
|
|
1732
|
+
return {
|
|
1733
|
+
async generate(data) {
|
|
1734
|
+
const body = { prompt: data.prompt };
|
|
1735
|
+
if (data.voiceProfileUid) {
|
|
1736
|
+
body.voice_profile_uid = data.voiceProfileUid;
|
|
1737
|
+
}
|
|
1738
|
+
if (data.useKnowledgeVault !== void 0) {
|
|
1739
|
+
body.knowledge_vault = data.useKnowledgeVault;
|
|
1740
|
+
}
|
|
1741
|
+
const response = await http.post(
|
|
1742
|
+
"/v1/generative-ai/generate",
|
|
1743
|
+
body
|
|
1744
|
+
);
|
|
1745
|
+
return response.data.data;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// src/vue/composables/shared/useQuery.ts
|
|
1751
|
+
var import_vue2 = require("vue");
|
|
1752
|
+
|
|
1753
|
+
// src/vue/provider/context.ts
|
|
1754
|
+
var import_vue = require("vue");
|
|
1755
|
+
var CONTENTSTACK_KEY = /* @__PURE__ */ Symbol("contentstack");
|
|
1756
|
+
function useContentstackContext() {
|
|
1757
|
+
const ctx = (0, import_vue.inject)(CONTENTSTACK_KEY);
|
|
1758
|
+
if (!ctx) {
|
|
1759
|
+
throw new Error(
|
|
1760
|
+
'useContentstackContext must be used within a <ContentstackProvider>. Wrap your app with <ContentstackProvider :region="..." proxy-base-path="/api/cma">.'
|
|
1761
|
+
);
|
|
1762
|
+
}
|
|
1763
|
+
return ctx;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// src/vue/composables/shared/useQuery.ts
|
|
1767
|
+
function useQuery(path, params, options) {
|
|
1768
|
+
const { proxyBasePath } = useContentstackContext();
|
|
1769
|
+
const data = (0, import_vue2.ref)(void 0);
|
|
1770
|
+
const loading = (0, import_vue2.ref)(false);
|
|
1771
|
+
const error = (0, import_vue2.ref)(null);
|
|
1772
|
+
let abortController = null;
|
|
1773
|
+
let intervalId = null;
|
|
1774
|
+
const isClient = typeof window !== "undefined";
|
|
1775
|
+
const enabled = options?.enabled ?? true;
|
|
1776
|
+
const refetchInterval = options?.refetchInterval ?? 0;
|
|
1777
|
+
async function fetchData(signal) {
|
|
1778
|
+
loading.value = true;
|
|
1779
|
+
error.value = null;
|
|
1780
|
+
const currentPath = (0, import_vue2.toValue)(path);
|
|
1781
|
+
const currentParams = (0, import_vue2.toValue)(params);
|
|
1782
|
+
const search = currentParams ? `?${new URLSearchParams(currentParams).toString()}` : "";
|
|
1783
|
+
const url = `${proxyBasePath}${currentPath}${search}`;
|
|
1784
|
+
try {
|
|
1785
|
+
const response = await fetch(url, { signal });
|
|
1786
|
+
if (signal?.aborted) return;
|
|
1787
|
+
if (!response.ok) {
|
|
1788
|
+
const err = await parseErrorResponse(response, currentPath);
|
|
1789
|
+
error.value = err;
|
|
1790
|
+
data.value = void 0;
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
const json = await response.json();
|
|
1794
|
+
data.value = json;
|
|
1795
|
+
} catch (err) {
|
|
1796
|
+
if (err instanceof DOMException && err.name === "AbortError") return;
|
|
1797
|
+
error.value = new ContentstackError(err instanceof Error ? err.message : "Network error", {
|
|
1798
|
+
requestPath: currentPath,
|
|
1799
|
+
cause: err instanceof Error ? err : void 0
|
|
1800
|
+
});
|
|
1801
|
+
data.value = void 0;
|
|
1802
|
+
} finally {
|
|
1803
|
+
if (!signal?.aborted) {
|
|
1804
|
+
loading.value = false;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
function doFetch() {
|
|
1809
|
+
abortController?.abort();
|
|
1810
|
+
const controller = new AbortController();
|
|
1811
|
+
abortController = controller;
|
|
1812
|
+
fetchData(controller.signal);
|
|
1813
|
+
}
|
|
1814
|
+
async function refetch() {
|
|
1815
|
+
abortController?.abort();
|
|
1816
|
+
const controller = new AbortController();
|
|
1817
|
+
abortController = controller;
|
|
1818
|
+
await fetchData(controller.signal);
|
|
1819
|
+
}
|
|
1820
|
+
(0, import_vue2.watch)(
|
|
1821
|
+
() => ({ path: (0, import_vue2.toValue)(path), params: (0, import_vue2.toValue)(params), enabled: (0, import_vue2.toValue)(enabled) }),
|
|
1822
|
+
(newVal) => {
|
|
1823
|
+
if (!newVal.enabled || !isClient) return;
|
|
1824
|
+
doFetch();
|
|
1825
|
+
},
|
|
1826
|
+
{ immediate: true, deep: true }
|
|
1827
|
+
);
|
|
1828
|
+
(0, import_vue2.watch)(
|
|
1829
|
+
() => ({ enabled: (0, import_vue2.toValue)(enabled), refetchInterval }),
|
|
1830
|
+
(newVal) => {
|
|
1831
|
+
if (intervalId) {
|
|
1832
|
+
clearInterval(intervalId);
|
|
1833
|
+
intervalId = null;
|
|
1834
|
+
}
|
|
1835
|
+
if (isClient && newVal.enabled && newVal.refetchInterval > 0) {
|
|
1836
|
+
intervalId = setInterval(() => {
|
|
1837
|
+
doFetch();
|
|
1838
|
+
}, newVal.refetchInterval);
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
{ immediate: true }
|
|
1842
|
+
);
|
|
1843
|
+
(0, import_vue2.onUnmounted)(() => {
|
|
1844
|
+
abortController?.abort();
|
|
1845
|
+
if (intervalId) {
|
|
1846
|
+
clearInterval(intervalId);
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
return { data, loading, error, refetch };
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
// src/vue/composables/useEntries.ts
|
|
1853
|
+
function useEntries(contentTypeUid, options) {
|
|
1854
|
+
const params = (0, import_vue3.computed)(() => buildEntriesParams(options));
|
|
1855
|
+
const path = (0, import_vue3.computed)(() => `/content_types/${(0, import_vue3.toValue)(contentTypeUid)}/entries`);
|
|
1856
|
+
const result = useQuery(path, params, options);
|
|
1857
|
+
const data = (0, import_vue3.computed)(() => result.data.value?.entries);
|
|
1858
|
+
const count = (0, import_vue3.computed)(() => result.data.value?.count);
|
|
1859
|
+
return {
|
|
1860
|
+
...result,
|
|
1861
|
+
data,
|
|
1862
|
+
count
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
// src/vue/composables/useEntry.ts
|
|
1867
|
+
var import_vue4 = require("vue");
|
|
1868
|
+
function useEntry(contentTypeUid, entryUid, options) {
|
|
1869
|
+
const params = (0, import_vue4.computed)(() => buildEntryParams(options));
|
|
1870
|
+
const path = (0, import_vue4.computed)(
|
|
1871
|
+
() => `/content_types/${(0, import_vue4.toValue)(contentTypeUid)}/entries/${(0, import_vue4.toValue)(entryUid)}`
|
|
1872
|
+
);
|
|
1873
|
+
const result = useQuery(path, params, options);
|
|
1874
|
+
const data = (0, import_vue4.computed)(() => result.data.value?.entry);
|
|
1875
|
+
return {
|
|
1876
|
+
...result,
|
|
1877
|
+
data
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// src/vue/composables/useAssets.ts
|
|
1882
|
+
var import_vue5 = require("vue");
|
|
1883
|
+
function useAssets(options) {
|
|
1884
|
+
const params = (0, import_vue5.computed)(() => buildAssetsParams(options));
|
|
1885
|
+
const result = useQuery("/assets", params, options);
|
|
1886
|
+
const data = (0, import_vue5.computed)(() => result.data.value?.assets);
|
|
1887
|
+
return {
|
|
1888
|
+
...result,
|
|
1889
|
+
data
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
// src/vue/composables/useContentTypes.ts
|
|
1894
|
+
var import_vue6 = require("vue");
|
|
1895
|
+
function useContentTypes(options) {
|
|
1896
|
+
const result = useQuery("/content_types", void 0, options);
|
|
1897
|
+
const data = (0, import_vue6.computed)(() => result.data.value?.content_types);
|
|
1898
|
+
return {
|
|
1899
|
+
...result,
|
|
1900
|
+
data
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
// src/vue/composables/useCMA.ts
|
|
1905
|
+
var import_vue7 = require("vue");
|
|
1906
|
+
function useCMA() {
|
|
1907
|
+
const { proxyBasePath, region, apiKey } = useContentstackContext();
|
|
1908
|
+
const client = (0, import_vue7.computed)(
|
|
1909
|
+
() => createCMAClient({
|
|
1910
|
+
region,
|
|
1911
|
+
apiKey: apiKey ?? "proxy",
|
|
1912
|
+
auth: { type: "oauth", accessToken: "proxy" },
|
|
1913
|
+
httpOptions: { baseUrl: proxyBasePath }
|
|
1914
|
+
})
|
|
1915
|
+
);
|
|
1916
|
+
return client.value;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
// src/vue/composables/useLaunch.ts
|
|
1920
|
+
var import_vue8 = require("vue");
|
|
1921
|
+
function useLaunch() {
|
|
1922
|
+
const { launchProxyBasePath = "/api/launch", region, organizationUid } = useContentstackContext();
|
|
1923
|
+
const client = (0, import_vue8.computed)(
|
|
1924
|
+
() => createLaunchClient({
|
|
1925
|
+
region,
|
|
1926
|
+
organizationUid: organizationUid ?? "proxy",
|
|
1927
|
+
auth: { type: "oauth", accessToken: "proxy" },
|
|
1928
|
+
httpOptions: { baseUrl: launchProxyBasePath }
|
|
1929
|
+
})
|
|
1930
|
+
);
|
|
1931
|
+
return client.value;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
// src/vue/composables/useBrandKit.ts
|
|
1935
|
+
var import_vue9 = require("vue");
|
|
1936
|
+
function useBrandKit() {
|
|
1937
|
+
const {
|
|
1938
|
+
brandKitProxyBasePath = "/api/brandkit",
|
|
1939
|
+
region,
|
|
1940
|
+
organizationUid
|
|
1941
|
+
} = useContentstackContext();
|
|
1942
|
+
const client = (0, import_vue9.computed)(
|
|
1943
|
+
() => createBrandKitClient({
|
|
1944
|
+
region,
|
|
1945
|
+
organizationUid: organizationUid ?? "proxy",
|
|
1946
|
+
auth: { type: "oauth", accessToken: "proxy" },
|
|
1947
|
+
httpOptions: { baseUrl: brandKitProxyBasePath }
|
|
1948
|
+
})
|
|
1949
|
+
);
|
|
1950
|
+
return client.value;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
// src/vue/composables/useKnowledgeVault.ts
|
|
1954
|
+
var import_vue10 = require("vue");
|
|
1955
|
+
function useKnowledgeVault() {
|
|
1956
|
+
const {
|
|
1957
|
+
brandKitProxyBasePath = "/api/brandkit",
|
|
1958
|
+
region,
|
|
1959
|
+
organizationUid,
|
|
1960
|
+
brandKitUid
|
|
1961
|
+
} = useContentstackContext();
|
|
1962
|
+
const client = (0, import_vue10.computed)(
|
|
1963
|
+
() => createKnowledgeVaultClient({
|
|
1964
|
+
region,
|
|
1965
|
+
organizationUid: organizationUid ?? "proxy",
|
|
1966
|
+
brandKitUid: brandKitUid ?? "proxy",
|
|
1967
|
+
auth: { type: "oauth", accessToken: "proxy" },
|
|
1968
|
+
httpOptions: { baseUrl: brandKitProxyBasePath }
|
|
1969
|
+
})
|
|
1970
|
+
);
|
|
1971
|
+
return client.value;
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
// src/vue/composables/useGenerativeAI.ts
|
|
1975
|
+
var import_vue11 = require("vue");
|
|
1976
|
+
function useGenerativeAI() {
|
|
1977
|
+
const {
|
|
1978
|
+
brandKitProxyBasePath = "/api/brandkit",
|
|
1979
|
+
region,
|
|
1980
|
+
organizationUid,
|
|
1981
|
+
brandKitUid
|
|
1982
|
+
} = useContentstackContext();
|
|
1983
|
+
const client = (0, import_vue11.computed)(
|
|
1984
|
+
() => createGenerativeAIClient({
|
|
1985
|
+
region,
|
|
1986
|
+
organizationUid: organizationUid ?? "proxy",
|
|
1987
|
+
brandKitUid: brandKitUid ?? "proxy",
|
|
1988
|
+
auth: { type: "oauth", accessToken: "proxy" },
|
|
1989
|
+
httpOptions: { baseUrl: brandKitProxyBasePath }
|
|
1990
|
+
})
|
|
1991
|
+
);
|
|
1992
|
+
return client.value;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
// src/vue/composables/shared/useMutation.ts
|
|
1996
|
+
var import_vue12 = require("vue");
|
|
1997
|
+
function useMutation(method, buildRequest) {
|
|
1998
|
+
const { proxyBasePath } = useContentstackContext();
|
|
1999
|
+
const data = (0, import_vue12.ref)(void 0);
|
|
2000
|
+
const loading = (0, import_vue12.ref)(false);
|
|
2001
|
+
const error = (0, import_vue12.ref)(null);
|
|
2002
|
+
const currentBuildRequest = buildRequest;
|
|
2003
|
+
async function mutate(variables) {
|
|
2004
|
+
const { path, body } = currentBuildRequest(variables);
|
|
2005
|
+
const url = `${proxyBasePath}${path}`;
|
|
2006
|
+
loading.value = true;
|
|
2007
|
+
error.value = null;
|
|
2008
|
+
try {
|
|
2009
|
+
const response = await fetch(url, {
|
|
2010
|
+
method,
|
|
2011
|
+
headers: body !== void 0 ? { "Content-Type": "application/json" } : void 0,
|
|
2012
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
2013
|
+
});
|
|
2014
|
+
if (!response.ok) {
|
|
2015
|
+
const err = await parseErrorResponse(response, path);
|
|
2016
|
+
error.value = err;
|
|
2017
|
+
data.value = void 0;
|
|
2018
|
+
throw err;
|
|
2019
|
+
}
|
|
2020
|
+
let json;
|
|
2021
|
+
try {
|
|
2022
|
+
json = await response.json();
|
|
2023
|
+
} catch {
|
|
2024
|
+
json = void 0;
|
|
2025
|
+
}
|
|
2026
|
+
data.value = json;
|
|
2027
|
+
return json;
|
|
2028
|
+
} catch (err) {
|
|
2029
|
+
if (err instanceof ContentstackError) throw err;
|
|
2030
|
+
const csError = new ContentstackError(err instanceof Error ? err.message : "Network error", {
|
|
2031
|
+
requestPath: path,
|
|
2032
|
+
cause: err instanceof Error ? err : void 0
|
|
2033
|
+
});
|
|
2034
|
+
error.value = csError;
|
|
2035
|
+
data.value = void 0;
|
|
2036
|
+
throw csError;
|
|
2037
|
+
} finally {
|
|
2038
|
+
loading.value = false;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
function reset() {
|
|
2042
|
+
data.value = void 0;
|
|
2043
|
+
error.value = null;
|
|
2044
|
+
}
|
|
2045
|
+
return { mutate, loading, error, data, reset };
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
// src/vue/composables/usePublishEntry.ts
|
|
2049
|
+
function usePublishEntry() {
|
|
2050
|
+
return useMutation("POST", buildPublishEntryRequest);
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
// src/vue/composables/useCreateEntry.ts
|
|
2054
|
+
var import_vue13 = require("vue");
|
|
2055
|
+
function useCreateEntry() {
|
|
2056
|
+
const result = useMutation(
|
|
2057
|
+
"POST",
|
|
2058
|
+
buildCreateEntryRequest
|
|
2059
|
+
);
|
|
2060
|
+
const data = (0, import_vue13.computed)(() => result.data.value?.entry);
|
|
2061
|
+
async function mutate(variables) {
|
|
2062
|
+
const raw = await result.mutate(variables);
|
|
2063
|
+
return raw.entry;
|
|
2064
|
+
}
|
|
2065
|
+
return {
|
|
2066
|
+
...result,
|
|
2067
|
+
data,
|
|
2068
|
+
mutate
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
// src/vue/composables/useUpdateEntry.ts
|
|
2073
|
+
var import_vue14 = require("vue");
|
|
2074
|
+
function useUpdateEntry() {
|
|
2075
|
+
const result = useMutation("PUT", buildUpdateEntryRequest);
|
|
2076
|
+
const data = (0, import_vue14.computed)(() => result.data.value?.entry);
|
|
2077
|
+
async function mutate(variables) {
|
|
2078
|
+
const raw = await result.mutate(variables);
|
|
2079
|
+
return raw.entry;
|
|
2080
|
+
}
|
|
2081
|
+
return {
|
|
2082
|
+
...result,
|
|
2083
|
+
data,
|
|
2084
|
+
mutate
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
// src/vue/composables/useDeleteEntry.ts
|
|
2089
|
+
function useDeleteEntry() {
|
|
2090
|
+
return useMutation("DELETE", buildDeleteEntryRequest);
|
|
2091
|
+
}
|
|
2092
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2093
|
+
0 && (module.exports = {
|
|
2094
|
+
useAssets,
|
|
2095
|
+
useBrandKit,
|
|
2096
|
+
useCMA,
|
|
2097
|
+
useContentTypes,
|
|
2098
|
+
useCreateEntry,
|
|
2099
|
+
useDeleteEntry,
|
|
2100
|
+
useEntries,
|
|
2101
|
+
useEntry,
|
|
2102
|
+
useGenerativeAI,
|
|
2103
|
+
useKnowledgeVault,
|
|
2104
|
+
useLaunch,
|
|
2105
|
+
usePublishEntry,
|
|
2106
|
+
useUpdateEntry
|
|
2107
|
+
});
|
|
2108
|
+
//# sourceMappingURL=index.cjs.map
|