@uniformdev/next-app-router 20.81.0 → 20.81.1-alpha.7.sha-91a5b13e0c
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/{UniformComposition-DBO-oo7J.d.ts → UniformComposition-C00_YDOg.d.ts} +11 -31
- package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-DiArCpVQ.d.mts} +11 -31
- package/dist/cache.d.mts +24 -6
- package/dist/cache.d.ts +24 -6
- package/dist/cache.js +410 -831
- package/dist/cache.mjs +405 -829
- package/dist/compat.d.mts +2 -4
- package/dist/compat.d.ts +2 -4
- package/dist/component.d.mts +10 -1
- package/dist/component.d.ts +10 -1
- package/dist/component.js +113 -617
- package/dist/component.mjs +112 -640
- package/dist/composition-BvOM-LIW.d.mts +28 -0
- package/dist/composition-BvOM-LIW.d.ts +28 -0
- package/dist/config/default.js +0 -1
- package/dist/config/default.mjs +0 -1
- package/dist/createCachedManifestProvider-C7faGJJ8.d.mts +69 -0
- package/dist/createCachedManifestProvider-C7faGJJ8.d.ts +69 -0
- package/dist/edge.d.mts +57 -0
- package/dist/edge.d.ts +57 -0
- package/dist/edge.js +1105 -0
- package/dist/edge.mjs +1073 -0
- package/dist/handler.d.mts +15 -2
- package/dist/handler.d.ts +15 -2
- package/dist/handler.js +134 -628
- package/dist/handler.mjs +132 -626
- package/dist/index.d.mts +73 -42
- package/dist/index.d.ts +73 -42
- package/dist/index.esm.js +2032 -5629
- package/dist/index.js +2068 -5661
- package/dist/index.mjs +2032 -5629
- package/dist/middleware.d.mts +52 -13
- package/dist/middleware.d.ts +52 -13
- package/dist/middleware.js +410 -5746
- package/dist/middleware.mjs +417 -5776
- package/dist/resolveRouteFromPath-BHJGOpBN.d.ts +82 -0
- package/dist/resolveRouteFromPath-BsZUVkRX.d.mts +82 -0
- package/dist/vercel.d.mts +24 -0
- package/dist/vercel.d.ts +24 -0
- package/dist/vercel.js +703 -0
- package/dist/vercel.mjs +675 -0
- package/package.json +37 -9
- package/dist/client-BElN_CWD.d.mts +0 -786
- package/dist/client-BElN_CWD.d.ts +0 -786
- package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +0 -18
- package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +0 -18
package/dist/vercel.js
ADDED
|
@@ -0,0 +1,703 @@
|
|
|
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/vercel.ts
|
|
21
|
+
var vercel_exports = {};
|
|
22
|
+
__export(vercel_exports, {
|
|
23
|
+
expireVercelRuntimeCacheTags: () => expireVercelRuntimeCacheTags,
|
|
24
|
+
vercelManifestProvider: () => vercelManifestProvider
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(vercel_exports);
|
|
27
|
+
|
|
28
|
+
// src/vercel/expireVercelRuntimeCacheTags.ts
|
|
29
|
+
var import_functions = require("@vercel/functions");
|
|
30
|
+
|
|
31
|
+
// src/vercel/isRuntimeCacheAvailable.ts
|
|
32
|
+
var isRuntimeCacheAvailable = () => process.env.NODE_ENV !== "development" || Boolean(process.env.RUNTIME_CACHE_ENDPOINT);
|
|
33
|
+
|
|
34
|
+
// src/vercel/expireVercelRuntimeCacheTags.ts
|
|
35
|
+
var expireVercelRuntimeCacheTags = async (tags) => {
|
|
36
|
+
if (!tags.length || !isRuntimeCacheAvailable()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await (0, import_functions.getCache)().expireTag(tags);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/vercel/vercelManifestProvider.ts
|
|
43
|
+
var import_functions2 = require("@vercel/functions");
|
|
44
|
+
|
|
45
|
+
// src/clients/manifest.ts
|
|
46
|
+
var import_server_only = require("server-only");
|
|
47
|
+
|
|
48
|
+
// ../canvas/dist/index.mjs
|
|
49
|
+
var import_api = require("@uniformdev/context/api");
|
|
50
|
+
var import_api2 = require("@uniformdev/context/api");
|
|
51
|
+
var import_api3 = require("@uniformdev/context/api");
|
|
52
|
+
var import_api4 = require("@uniformdev/context/api");
|
|
53
|
+
var import_api5 = require("@uniformdev/context/api");
|
|
54
|
+
var import_api6 = require("@uniformdev/context/api");
|
|
55
|
+
var import_api7 = require("@uniformdev/context/api");
|
|
56
|
+
var import_api8 = require("@uniformdev/context/api");
|
|
57
|
+
var import_api9 = require("@uniformdev/context/api");
|
|
58
|
+
var import_api10 = require("@uniformdev/context/api");
|
|
59
|
+
var import_api11 = require("@uniformdev/context/api");
|
|
60
|
+
var import_api12 = require("@uniformdev/context/api");
|
|
61
|
+
var import_api13 = require("@uniformdev/context/api");
|
|
62
|
+
var import_api14 = require("@uniformdev/context/api");
|
|
63
|
+
var import_api15 = require("@uniformdev/context/api");
|
|
64
|
+
var import_api16 = require("@uniformdev/context/api");
|
|
65
|
+
var import_api17 = require("@uniformdev/context/api");
|
|
66
|
+
var import_api18 = require("@uniformdev/context/api");
|
|
67
|
+
var import_api19 = require("@uniformdev/context/api");
|
|
68
|
+
var import_api20 = require("@uniformdev/context/api");
|
|
69
|
+
var import_api21 = require("@uniformdev/context/api");
|
|
70
|
+
var import_api22 = require("@uniformdev/context/api");
|
|
71
|
+
var import_api23 = require("@uniformdev/context/api");
|
|
72
|
+
var import_api24 = require("@uniformdev/context/api");
|
|
73
|
+
var import_api25 = require("@uniformdev/context/api");
|
|
74
|
+
var import_api26 = require("@uniformdev/context/api");
|
|
75
|
+
var import_api27 = require("@uniformdev/context/api");
|
|
76
|
+
var __typeError = (msg) => {
|
|
77
|
+
throw TypeError(msg);
|
|
78
|
+
};
|
|
79
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
80
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
81
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
82
|
+
var SELECT_QUERY_PREFIX = "select.";
|
|
83
|
+
function appendCsv(out, key, values) {
|
|
84
|
+
if (values === void 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
out[key] = values.join(",");
|
|
88
|
+
}
|
|
89
|
+
function projectionToQuery(spec) {
|
|
90
|
+
const out = {};
|
|
91
|
+
if (!spec) {
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
const { fields, fieldTypes, slots } = spec;
|
|
95
|
+
const p = SELECT_QUERY_PREFIX;
|
|
96
|
+
if (fields) {
|
|
97
|
+
appendCsv(out, `${p}fields[only]`, fields.only);
|
|
98
|
+
appendCsv(out, `${p}fields[except]`, fields.except);
|
|
99
|
+
appendCsv(out, `${p}fields[locales]`, fields.locales);
|
|
100
|
+
if (fields.blockDepth === "preserveAll" || typeof fields.blockDepth === "number") {
|
|
101
|
+
out[`${p}fields[blockDepth]`] = String(fields.blockDepth);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (fieldTypes) {
|
|
105
|
+
appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
|
|
106
|
+
appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
|
|
107
|
+
}
|
|
108
|
+
if (slots) {
|
|
109
|
+
appendCsv(out, `${p}slots[only]`, slots.only);
|
|
110
|
+
appendCsv(out, `${p}slots[except]`, slots.except);
|
|
111
|
+
if (typeof slots.depth === "number") {
|
|
112
|
+
out[`${p}slots[depth]`] = String(slots.depth);
|
|
113
|
+
}
|
|
114
|
+
if (slots.named) {
|
|
115
|
+
const slotNames = Object.keys(slots.named).sort();
|
|
116
|
+
for (const slotName of slotNames) {
|
|
117
|
+
const named = slots.named[slotName];
|
|
118
|
+
if (named && typeof named.depth === "number") {
|
|
119
|
+
out[`${p}slots.${slotName}[depth]`] = String(named.depth);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
var CANVAS_DRAFT_STATE = 0;
|
|
127
|
+
var CANVAS_EDITOR_STATE = 63;
|
|
128
|
+
var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
|
|
129
|
+
var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
|
|
130
|
+
var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
|
|
131
|
+
var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
132
|
+
var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
|
|
133
|
+
var _contentTypesUrl;
|
|
134
|
+
var _entriesUrl;
|
|
135
|
+
var _ContentClient = class _ContentClient2 extends import_api12.ApiClient {
|
|
136
|
+
constructor(options) {
|
|
137
|
+
var _a;
|
|
138
|
+
super(options);
|
|
139
|
+
this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
|
|
140
|
+
}
|
|
141
|
+
getContentTypes(options) {
|
|
142
|
+
const { projectId } = this.options;
|
|
143
|
+
const fetchUri = this.createUrl(__privateGet(_ContentClient2, _contentTypesUrl), { ...options, projectId });
|
|
144
|
+
return this.apiClient(fetchUri);
|
|
145
|
+
}
|
|
146
|
+
getEntries(options) {
|
|
147
|
+
const { projectId } = this.options;
|
|
148
|
+
const { skipDataResolution, filters, select, ...params } = options;
|
|
149
|
+
const rewrittenFilters = (0, import_api12.rewriteFiltersForApi)(filters);
|
|
150
|
+
const rewrittenSelect = projectionToQuery(select);
|
|
151
|
+
if (skipDataResolution) {
|
|
152
|
+
const url = this.createUrl(__privateGet(_ContentClient2, _entriesUrl), {
|
|
153
|
+
...params,
|
|
154
|
+
...rewrittenFilters,
|
|
155
|
+
...rewrittenSelect,
|
|
156
|
+
projectId
|
|
157
|
+
});
|
|
158
|
+
return this.apiClient(url);
|
|
159
|
+
}
|
|
160
|
+
const edgeUrl = this.createUrl(
|
|
161
|
+
__privateGet(_ContentClient2, _entriesUrl),
|
|
162
|
+
{ ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
|
|
163
|
+
this.edgeApiHost
|
|
164
|
+
);
|
|
165
|
+
return this.apiClient(
|
|
166
|
+
edgeUrl,
|
|
167
|
+
this.options.disableSWR ? { headers: { "x-disable-swr": "true" } } : void 0
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
/** Fetches historical versions of an entry */
|
|
171
|
+
async getEntryHistory(options) {
|
|
172
|
+
const historyUrl = this.createUrl("/api/v1/entries-history", {
|
|
173
|
+
...options,
|
|
174
|
+
projectId: this.options.projectId
|
|
175
|
+
});
|
|
176
|
+
return this.apiClient(historyUrl);
|
|
177
|
+
}
|
|
178
|
+
async upsertContentType(body, opts = {}) {
|
|
179
|
+
const fetchUri = this.createUrl(__privateGet(_ContentClient2, _contentTypesUrl));
|
|
180
|
+
if (typeof body.contentType.slugSettings === "object" && body.contentType.slugSettings !== null && Object.keys(body.contentType.slugSettings).length === 0) {
|
|
181
|
+
delete body.contentType.slugSettings;
|
|
182
|
+
}
|
|
183
|
+
await this.apiClient(fetchUri, {
|
|
184
|
+
method: "PUT",
|
|
185
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
186
|
+
expectNoContent: true,
|
|
187
|
+
headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async upsertEntry(body, options) {
|
|
191
|
+
const fetchUri = this.createUrl(__privateGet(_ContentClient2, _entriesUrl));
|
|
192
|
+
const headers = {};
|
|
193
|
+
if (options == null ? void 0 : options.ifUnmodifiedSince) {
|
|
194
|
+
headers["x-if-unmodified-since"] = options.ifUnmodifiedSince;
|
|
195
|
+
}
|
|
196
|
+
const { response } = await this.apiClientWithResponse(fetchUri, {
|
|
197
|
+
method: "PUT",
|
|
198
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
199
|
+
expectNoContent: true,
|
|
200
|
+
headers
|
|
201
|
+
});
|
|
202
|
+
return { modified: response.headers.get("x-modified-at") };
|
|
203
|
+
}
|
|
204
|
+
async deleteContentType(body) {
|
|
205
|
+
const fetchUri = this.createUrl(__privateGet(_ContentClient2, _contentTypesUrl));
|
|
206
|
+
await this.apiClient(fetchUri, {
|
|
207
|
+
method: "DELETE",
|
|
208
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
209
|
+
expectNoContent: true
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async deleteEntry(body) {
|
|
213
|
+
const fetchUri = this.createUrl(__privateGet(_ContentClient2, _entriesUrl));
|
|
214
|
+
await this.apiClient(fetchUri, {
|
|
215
|
+
method: "DELETE",
|
|
216
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
217
|
+
expectNoContent: true
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
getEdgeOptions(options) {
|
|
221
|
+
const { projectId } = this.options;
|
|
222
|
+
const { skipDataResolution, ...params } = options;
|
|
223
|
+
return {
|
|
224
|
+
projectId,
|
|
225
|
+
...params,
|
|
226
|
+
diagnostics: typeof options.diagnostics === "boolean" ? options.diagnostics : options.diagnostics === "no-data" ? "no-data" : void 0
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
_contentTypesUrl = /* @__PURE__ */ new WeakMap();
|
|
231
|
+
_entriesUrl = /* @__PURE__ */ new WeakMap();
|
|
232
|
+
__privateAdd(_ContentClient, _contentTypesUrl, "/api/v1/content-types");
|
|
233
|
+
__privateAdd(_ContentClient, _entriesUrl, "/api/v1/entries");
|
|
234
|
+
var _url;
|
|
235
|
+
var _DataTypeClient = class _DataTypeClient2 extends import_api14.ApiClient {
|
|
236
|
+
constructor(options) {
|
|
237
|
+
super(options);
|
|
238
|
+
}
|
|
239
|
+
/** Fetches a list of DataTypes for a project */
|
|
240
|
+
async list(options) {
|
|
241
|
+
const { projectId } = this.options;
|
|
242
|
+
const fetchUri = this.createUrl(__privateGet(_DataTypeClient2, _url), { ...options, projectId });
|
|
243
|
+
return await this.apiClient(fetchUri);
|
|
244
|
+
}
|
|
245
|
+
/** @deprecated Use {@link list} instead. */
|
|
246
|
+
async get(options) {
|
|
247
|
+
return this.list(options);
|
|
248
|
+
}
|
|
249
|
+
/** Updates or creates (based on id) a DataType */
|
|
250
|
+
async save(body) {
|
|
251
|
+
const fetchUri = this.createUrl(__privateGet(_DataTypeClient2, _url));
|
|
252
|
+
await this.apiClient(fetchUri, {
|
|
253
|
+
method: "PUT",
|
|
254
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
255
|
+
expectNoContent: true
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** @deprecated Use {@link save} instead. */
|
|
259
|
+
async upsert(body) {
|
|
260
|
+
return this.save(body);
|
|
261
|
+
}
|
|
262
|
+
/** Deletes a DataType */
|
|
263
|
+
async remove(body) {
|
|
264
|
+
const fetchUri = this.createUrl(__privateGet(_DataTypeClient2, _url));
|
|
265
|
+
await this.apiClient(fetchUri, {
|
|
266
|
+
method: "DELETE",
|
|
267
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
|
268
|
+
expectNoContent: true
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
273
|
+
__privateAdd(_DataTypeClient, _url, "/api/v1/data-types");
|
|
274
|
+
var _baseUrl;
|
|
275
|
+
var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends import_api16.ApiClient {
|
|
276
|
+
constructor(options) {
|
|
277
|
+
super(options);
|
|
278
|
+
this.teamId = options.teamId;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Gets a list of property type and hook names for the current team, including public integrations' hooks.
|
|
282
|
+
*/
|
|
283
|
+
get(options) {
|
|
284
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationPropertyEditorsClient2, _baseUrl), {
|
|
285
|
+
...options,
|
|
286
|
+
teamId: this.teamId
|
|
287
|
+
});
|
|
288
|
+
return this.apiClient(fetchUri);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Creates or updates a custom AI property editor on a Mesh app.
|
|
292
|
+
*/
|
|
293
|
+
async deploy(body) {
|
|
294
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationPropertyEditorsClient2, _baseUrl));
|
|
295
|
+
await this.apiClient(fetchUri, {
|
|
296
|
+
method: "PUT",
|
|
297
|
+
body: JSON.stringify({ ...body, teamId: this.teamId }),
|
|
298
|
+
expectNoContent: true
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Removes a custom AI property editor from a Mesh app.
|
|
303
|
+
*/
|
|
304
|
+
async delete(body) {
|
|
305
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationPropertyEditorsClient2, _baseUrl));
|
|
306
|
+
await this.apiClient(fetchUri, {
|
|
307
|
+
method: "DELETE",
|
|
308
|
+
body: JSON.stringify({ ...body, teamId: this.teamId }),
|
|
309
|
+
expectNoContent: true
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
_baseUrl = /* @__PURE__ */ new WeakMap();
|
|
314
|
+
__privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
|
|
315
|
+
var _url2;
|
|
316
|
+
var _projectsUrl;
|
|
317
|
+
var _ProjectClient = class _ProjectClient2 extends import_api20.ApiClient {
|
|
318
|
+
constructor(options) {
|
|
319
|
+
super({ ...options, bypassCache: true });
|
|
320
|
+
}
|
|
321
|
+
/** Fetches single Project */
|
|
322
|
+
async get(options) {
|
|
323
|
+
const fetchUri = this.createUrl(__privateGet(_ProjectClient2, _url2), { ...options });
|
|
324
|
+
return await this.apiClient(fetchUri);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Fetches projects grouped by team.
|
|
328
|
+
* When teamId is provided, returns a single team with its projects.
|
|
329
|
+
* When omitted, returns all accessible teams and their projects.
|
|
330
|
+
*/
|
|
331
|
+
async list(options) {
|
|
332
|
+
const fetchUri = this.createUrl(__privateGet(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
|
|
333
|
+
return await this.apiClient(fetchUri);
|
|
334
|
+
}
|
|
335
|
+
/** @deprecated Use {@link list} instead. */
|
|
336
|
+
async getProjects(options) {
|
|
337
|
+
return this.list(options);
|
|
338
|
+
}
|
|
339
|
+
/** Updates or creates (based on id) a Project */
|
|
340
|
+
async save(body) {
|
|
341
|
+
const fetchUri = this.createUrl(__privateGet(_ProjectClient2, _url2));
|
|
342
|
+
return await this.apiClient(fetchUri, {
|
|
343
|
+
method: "PUT",
|
|
344
|
+
body: JSON.stringify({ ...body })
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/** @deprecated Use {@link save} instead. */
|
|
348
|
+
async upsert(body) {
|
|
349
|
+
return this.save(body);
|
|
350
|
+
}
|
|
351
|
+
/** Deletes a Project */
|
|
352
|
+
async remove(body) {
|
|
353
|
+
const fetchUri = this.createUrl(__privateGet(_ProjectClient2, _url2));
|
|
354
|
+
await this.apiClient(fetchUri, {
|
|
355
|
+
method: "DELETE",
|
|
356
|
+
body: JSON.stringify({ ...body }),
|
|
357
|
+
expectNoContent: true
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/** @deprecated Use {@link remove} instead. */
|
|
361
|
+
async delete(body) {
|
|
362
|
+
return this.remove(body);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
_url2 = /* @__PURE__ */ new WeakMap();
|
|
366
|
+
_projectsUrl = /* @__PURE__ */ new WeakMap();
|
|
367
|
+
__privateAdd(_ProjectClient, _url2, "/api/v1/project");
|
|
368
|
+
__privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
|
|
369
|
+
|
|
370
|
+
// src/clients/manifest.ts
|
|
371
|
+
var import_api29 = require("@uniformdev/context/api");
|
|
372
|
+
|
|
373
|
+
// src/utils/env.ts
|
|
374
|
+
var env = {
|
|
375
|
+
getProjectId: () => {
|
|
376
|
+
return process.env.UNIFORM_PROJECT_ID;
|
|
377
|
+
},
|
|
378
|
+
getApiKey: () => {
|
|
379
|
+
return process.env.UNIFORM_API_KEY;
|
|
380
|
+
},
|
|
381
|
+
getApiHost: () => {
|
|
382
|
+
return process.env.UNIFORM_API_HOST || process.env.UNIFORM_CLI_BASE_URL;
|
|
383
|
+
},
|
|
384
|
+
getEdgeApiHost: () => {
|
|
385
|
+
return process.env.UNIFORM_EDGE_API_HOST || process.env.UNIFORM_CLI_BASE_EDGE_URL;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// src/utils/draft.ts
|
|
390
|
+
var isDraftModeEnabled = ({
|
|
391
|
+
draftModeEnabled
|
|
392
|
+
}) => {
|
|
393
|
+
return draftModeEnabled;
|
|
394
|
+
};
|
|
395
|
+
var isIncontextEditingEnabled = ({
|
|
396
|
+
isDraftModeEnabled: isDraftModeEnabled2,
|
|
397
|
+
searchParams
|
|
398
|
+
}) => {
|
|
399
|
+
if (!isDraftModeEnabled2) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
const containsKey = searchParams.has(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM);
|
|
403
|
+
return containsKey;
|
|
404
|
+
};
|
|
405
|
+
var isDevelopmentEnvironment = () => {
|
|
406
|
+
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// src/clients/cache.ts
|
|
410
|
+
var isSpecificCacheMode = (options) => {
|
|
411
|
+
return "cache" in options;
|
|
412
|
+
};
|
|
413
|
+
var isStateCacheMode = (options) => {
|
|
414
|
+
return "state" in options;
|
|
415
|
+
};
|
|
416
|
+
var isDetectCacheMode = (options) => {
|
|
417
|
+
return "searchParams" in options && "draftModeEnabled" in options;
|
|
418
|
+
};
|
|
419
|
+
var resolveManifestCache = (options) => {
|
|
420
|
+
return resolveCache({
|
|
421
|
+
options
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
var resolveCache = ({
|
|
425
|
+
options
|
|
426
|
+
}) => {
|
|
427
|
+
let cache = void 0;
|
|
428
|
+
if (options) {
|
|
429
|
+
if (isSpecificCacheMode(options)) {
|
|
430
|
+
cache = options.cache;
|
|
431
|
+
} else if (isStateCacheMode(options)) {
|
|
432
|
+
if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
|
|
433
|
+
cache = {
|
|
434
|
+
type: "no-cache",
|
|
435
|
+
bypassCache: true
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
} else if (isDetectCacheMode(options)) {
|
|
439
|
+
const { disabled } = shouldCacheBeDisabled(options);
|
|
440
|
+
if (disabled) {
|
|
441
|
+
cache = {
|
|
442
|
+
type: "no-cache",
|
|
443
|
+
bypassCache: true
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return cache || {
|
|
449
|
+
type: "force-cache"
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
var shouldCacheBeDisabled = (options) => {
|
|
453
|
+
if (isDraftModeEnabled(options)) {
|
|
454
|
+
return { disabled: true, reason: "DRAFT" };
|
|
455
|
+
}
|
|
456
|
+
if (isIncontextEditingEnabled({
|
|
457
|
+
isDraftModeEnabled: options.draftModeEnabled,
|
|
458
|
+
searchParams: options.searchParams
|
|
459
|
+
})) {
|
|
460
|
+
return { disabled: true, reason: "INCONTEXT" };
|
|
461
|
+
}
|
|
462
|
+
if (isDevelopmentEnvironment()) {
|
|
463
|
+
return { disabled: true, reason: "DEV" };
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
disabled: false,
|
|
467
|
+
reason: void 0
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
var determineFetchCacheOptions = (mode) => {
|
|
471
|
+
let cache = void 0;
|
|
472
|
+
let revalidate = void 0;
|
|
473
|
+
if (mode.type === "revalidate") {
|
|
474
|
+
cache = void 0;
|
|
475
|
+
revalidate = mode.interval;
|
|
476
|
+
} else {
|
|
477
|
+
cache = mode.type;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
cache,
|
|
481
|
+
revalidate
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
// src/clients/retry.ts
|
|
486
|
+
var import_api28 = require("@uniformdev/context/api");
|
|
487
|
+
function createThrottler(limit, interval) {
|
|
488
|
+
let available = limit;
|
|
489
|
+
let refillScheduled = false;
|
|
490
|
+
const waiting = [];
|
|
491
|
+
function scheduleRefill() {
|
|
492
|
+
if (refillScheduled) return;
|
|
493
|
+
refillScheduled = true;
|
|
494
|
+
setTimeout(() => {
|
|
495
|
+
refillScheduled = false;
|
|
496
|
+
available = limit;
|
|
497
|
+
while (available > 0 && waiting.length > 0) {
|
|
498
|
+
available--;
|
|
499
|
+
const next = waiting.shift();
|
|
500
|
+
next();
|
|
501
|
+
}
|
|
502
|
+
if (waiting.length > 0) {
|
|
503
|
+
scheduleRefill();
|
|
504
|
+
}
|
|
505
|
+
}, interval);
|
|
506
|
+
}
|
|
507
|
+
return async function throttle(fn) {
|
|
508
|
+
if (available > 0) {
|
|
509
|
+
available--;
|
|
510
|
+
if (!refillScheduled) {
|
|
511
|
+
scheduleRefill();
|
|
512
|
+
}
|
|
513
|
+
return fn();
|
|
514
|
+
}
|
|
515
|
+
return new Promise((resolve, reject) => {
|
|
516
|
+
waiting.push(() => {
|
|
517
|
+
fn().then(resolve, reject);
|
|
518
|
+
});
|
|
519
|
+
scheduleRefill();
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function createLimiter(concurrency) {
|
|
524
|
+
let active = 0;
|
|
525
|
+
const queue = [];
|
|
526
|
+
return async function limit(fn) {
|
|
527
|
+
return new Promise((resolve, reject) => {
|
|
528
|
+
const run = async () => {
|
|
529
|
+
active++;
|
|
530
|
+
try {
|
|
531
|
+
const result = await fn();
|
|
532
|
+
resolve(result);
|
|
533
|
+
} catch (error) {
|
|
534
|
+
reject(error);
|
|
535
|
+
} finally {
|
|
536
|
+
active--;
|
|
537
|
+
if (queue.length > 0) {
|
|
538
|
+
const next = queue.shift();
|
|
539
|
+
next();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
if (active < concurrency) {
|
|
544
|
+
run();
|
|
545
|
+
} else {
|
|
546
|
+
queue.push(run);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
async function retry(fn, options) {
|
|
552
|
+
let lastError;
|
|
553
|
+
let delay = 1e3;
|
|
554
|
+
for (let attempt = 1; attempt <= options.retries + 1; attempt++) {
|
|
555
|
+
try {
|
|
556
|
+
return await fn();
|
|
557
|
+
} catch (error) {
|
|
558
|
+
lastError = error;
|
|
559
|
+
const attemptError = Object.assign(error, { attemptNumber: attempt });
|
|
560
|
+
if (options.onFailedAttempt) {
|
|
561
|
+
await options.onFailedAttempt(attemptError);
|
|
562
|
+
}
|
|
563
|
+
if (attempt > options.retries) {
|
|
564
|
+
throw error;
|
|
565
|
+
}
|
|
566
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
567
|
+
delay *= options.factor;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
throw lastError;
|
|
571
|
+
}
|
|
572
|
+
function createLimitPolicy({
|
|
573
|
+
throttle = { interval: 1e3, limit: 10 },
|
|
574
|
+
retry: retryOptions = { retries: 1, factor: 1.66 },
|
|
575
|
+
limit = 10
|
|
576
|
+
}) {
|
|
577
|
+
const throttler = throttle ? createThrottler(throttle.limit, throttle.interval) : null;
|
|
578
|
+
const limiter = limit ? createLimiter(limit) : null;
|
|
579
|
+
return function limitPolicy(func) {
|
|
580
|
+
let currentFunc = async () => await func();
|
|
581
|
+
if (throttler) {
|
|
582
|
+
const throttleFunc = currentFunc;
|
|
583
|
+
currentFunc = () => throttler(throttleFunc);
|
|
584
|
+
}
|
|
585
|
+
if (limiter) {
|
|
586
|
+
const limitFunc = currentFunc;
|
|
587
|
+
currentFunc = () => limiter(limitFunc);
|
|
588
|
+
}
|
|
589
|
+
if (retryOptions) {
|
|
590
|
+
const retryFunc = currentFunc;
|
|
591
|
+
currentFunc = () => retry(retryFunc, {
|
|
592
|
+
...retryOptions,
|
|
593
|
+
onFailedAttempt: async (error) => {
|
|
594
|
+
if (retryOptions.onFailedAttempt) {
|
|
595
|
+
await retryOptions.onFailedAttempt(error);
|
|
596
|
+
}
|
|
597
|
+
if (error instanceof import_api28.ApiClientError && typeof error.statusCode === "number" && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429 && error.statusCode !== 408) {
|
|
598
|
+
throw error;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
return currentFunc();
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/clients/tags.ts
|
|
608
|
+
var generateManifestCacheTags = () => {
|
|
609
|
+
return ["manifest"];
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// src/clients/manifest.ts
|
|
613
|
+
var getManifestClient = (options) => {
|
|
614
|
+
const cache = resolveManifestCache(options);
|
|
615
|
+
const manifestClient = new import_api29.ManifestClient({
|
|
616
|
+
apiHost: env.getApiHost(),
|
|
617
|
+
apiKey: env.getApiKey(),
|
|
618
|
+
projectId: env.getProjectId(),
|
|
619
|
+
limitPolicy: createLimitPolicy({
|
|
620
|
+
limit: 6
|
|
621
|
+
}),
|
|
622
|
+
fetch: (req, init) => {
|
|
623
|
+
const { cache: fetchCache, revalidate } = determineFetchCacheOptions(cache);
|
|
624
|
+
return fetch(req, {
|
|
625
|
+
...init,
|
|
626
|
+
headers: {
|
|
627
|
+
...init == null ? void 0 : init.headers,
|
|
628
|
+
"x-bypass-cache": typeof cache.bypassCache !== "undefined" ? cache.bypassCache.toString() : "false"
|
|
629
|
+
},
|
|
630
|
+
cache: fetchCache,
|
|
631
|
+
next: {
|
|
632
|
+
revalidate,
|
|
633
|
+
tags: generateManifestCacheTags()
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
return manifestClient;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// src/manifest/createCachedManifestProvider.ts
|
|
642
|
+
var createCachedManifestProvider = ({
|
|
643
|
+
cache,
|
|
644
|
+
fallback,
|
|
645
|
+
ttl = 3600,
|
|
646
|
+
maxAge = 10,
|
|
647
|
+
fetchManifest = fetchPublishedManifest
|
|
648
|
+
} = {}) => {
|
|
649
|
+
let current;
|
|
650
|
+
let pending;
|
|
651
|
+
const load = async ({ waitUntil }) => {
|
|
652
|
+
var _a;
|
|
653
|
+
const key = `uniform-manifest-${(_a = env.getProjectId()) != null ? _a : ""}`;
|
|
654
|
+
const cached = await (cache == null ? void 0 : cache.get(key).catch(() => void 0));
|
|
655
|
+
if (isManifest(cached)) {
|
|
656
|
+
return cached;
|
|
657
|
+
}
|
|
658
|
+
const manifest = await fetchManifest();
|
|
659
|
+
if (cache) {
|
|
660
|
+
waitUntil(cache.set(key, manifest, { ttl, tags: generateManifestCacheTags() }).catch(() => {
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
return manifest;
|
|
664
|
+
};
|
|
665
|
+
return async (options) => {
|
|
666
|
+
var _a;
|
|
667
|
+
if (current && Date.now() - current.loadedAt < maxAge * 1e3) {
|
|
668
|
+
return current.manifest;
|
|
669
|
+
}
|
|
670
|
+
pending != null ? pending : pending = load(options).then((manifest) => {
|
|
671
|
+
current = { manifest, loadedAt: Date.now() };
|
|
672
|
+
return manifest;
|
|
673
|
+
}).finally(() => {
|
|
674
|
+
pending = void 0;
|
|
675
|
+
});
|
|
676
|
+
try {
|
|
677
|
+
return await pending;
|
|
678
|
+
} catch (error) {
|
|
679
|
+
const known = (_a = current == null ? void 0 : current.manifest) != null ? _a : fallback;
|
|
680
|
+
if (known) {
|
|
681
|
+
return known;
|
|
682
|
+
}
|
|
683
|
+
throw error;
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
var fetchPublishedManifest = () => getManifestClient({ cache: { type: "no-store" } }).get({ preview: false });
|
|
688
|
+
var isManifest = (value) => typeof value === "object" && value !== null && "project" in value;
|
|
689
|
+
|
|
690
|
+
// src/vercel/vercelManifestProvider.ts
|
|
691
|
+
var runtimeCache = {
|
|
692
|
+
get: (key) => (0, import_functions2.getCache)().get(key),
|
|
693
|
+
set: (key, value, options) => (0, import_functions2.getCache)().set(key, value, options)
|
|
694
|
+
};
|
|
695
|
+
var vercelManifestProvider = (options = {}) => createCachedManifestProvider({
|
|
696
|
+
...options,
|
|
697
|
+
cache: isRuntimeCacheAvailable() ? runtimeCache : void 0
|
|
698
|
+
});
|
|
699
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
700
|
+
0 && (module.exports = {
|
|
701
|
+
expireVercelRuntimeCacheTags,
|
|
702
|
+
vercelManifestProvider
|
|
703
|
+
});
|