@sanity/cli 3.36.4 → 3.36.5-canary.34
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/lib/_chunks-cjs/cli.js +1779 -1317
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/journeyConfig.js +11 -11
- package/lib/_chunks-cjs/journeyConfig.js.map +1 -1
- package/lib/_chunks-cjs/loadEnv.js +105 -2719
- package/lib/_chunks-cjs/loadEnv.js.map +1 -1
- package/lib/cli.d.ts +10 -0
- package/lib/index.d.ts +448 -0
- package/lib/index.esm.js +449 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +452 -0
- package/lib/index.mjs.map +1 -0
- package/lib/run.d.ts +1 -0
- package/lib/workers/getAndWriteJourneySchema.d.ts +1 -0
- package/lib/workers/getCliConfig.d.ts +1 -0
- package/lib/workers/typegenGenerate.d.ts +37 -0
- package/lib/workers/typegenGenerate.js +6 -2
- package/lib/workers/typegenGenerate.js.map +1 -1
- package/package.json +18 -21
- package/src/actions/init-project/templates/shopify.ts +7 -0
- package/src/util/journeyConfig.ts +5 -5
- package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +1 -1
- package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +1 -1
- package/templates/shared/tsconfig.json +2 -4
- package/templates/shopify/README.md +3 -3
- package/templates/shopify/components/hotspots/ProductTooltip.tsx +1 -1
- package/templates/shopify/components/icons/Shopify.tsx +1 -1
- package/templates/shopify/components/inputs/CollectionHidden.tsx +1 -1
- package/templates/shopify/components/media/ColorTheme.tsx +1 -1
- package/templates/shopify/components/studio/Navbar.tsx +29 -0
- package/templates/shopify/constants.ts +31 -1
- package/templates/shopify/docs/features.md +6 -7
- package/templates/shopify/schemaTypes/documents/collection.tsx +11 -47
- package/templates/shopify/schemaTypes/documents/colorTheme.tsx +2 -17
- package/templates/shopify/schemaTypes/documents/page.ts +10 -37
- package/templates/shopify/schemaTypes/documents/product.tsx +4 -27
- package/templates/shopify/schemaTypes/documents/productVariant.tsx +4 -13
- package/templates/shopify/schemaTypes/index.ts +97 -126
- package/templates/shopify/schemaTypes/objects/collection/{group.ts → collectionGroupType.ts} +7 -10
- package/templates/shopify/schemaTypes/objects/collection/{links.ts → collectionLinksType.ts} +4 -4
- package/templates/shopify/schemaTypes/objects/customProductOption/{colorObject.tsx → customProductOptionColorObjectType.tsx} +3 -6
- package/templates/shopify/schemaTypes/objects/customProductOption/{color.tsx → customProductOptionColorType.tsx} +2 -10
- package/templates/shopify/schemaTypes/objects/customProductOption/{sizeObject.ts → customProductOptionSizeObjectType.ts} +3 -7
- package/templates/shopify/schemaTypes/objects/customProductOption/{size.ts → customProductOptionSizeType.ts} +3 -12
- package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
- package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
- package/templates/shopify/schemaTypes/objects/global/{menu.ts → menuType.ts} +2 -4
- package/templates/shopify/schemaTypes/objects/global/{notFoundPage.ts → notFoundPageType.ts} +1 -6
- package/templates/shopify/schemaTypes/objects/hotspot/{imageWithProductHotspots.ts → imageWithProductHotspotsType.ts} +4 -6
- package/templates/shopify/schemaTypes/objects/hotspot/{productHotspots.tsx → productHotspotsType.tsx} +3 -5
- package/templates/shopify/schemaTypes/objects/hotspot/{spot.tsx → spotType.tsx} +1 -3
- package/templates/shopify/schemaTypes/{annotations/linkEmail.tsx → objects/link/linkEmailType.tsx} +5 -13
- package/templates/shopify/schemaTypes/{annotations/linkExternal.tsx → objects/link/linkExternalType.tsx} +6 -13
- package/templates/shopify/schemaTypes/{annotations/linkInternal.tsx → objects/link/linkInternalType.tsx} +5 -12
- package/templates/shopify/schemaTypes/{annotations/product.tsx → objects/link/linkProductType.tsx} +4 -16
- package/templates/shopify/schemaTypes/objects/module/{accordionGroup.ts → accordionGroupType.ts} +6 -9
- package/templates/shopify/schemaTypes/objects/module/{accordion.ts → accordionType.ts} +4 -11
- package/templates/shopify/schemaTypes/objects/module/{callToAction.tsx → callToActionType.tsx} +10 -23
- package/templates/shopify/schemaTypes/objects/module/{callout.ts → calloutType.ts} +4 -10
- package/templates/shopify/schemaTypes/objects/module/{collection.tsx → collectionReferenceType.tsx} +4 -9
- package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
- package/templates/shopify/schemaTypes/objects/module/{grid.ts → gridType.ts} +7 -15
- package/templates/shopify/schemaTypes/objects/{hero/home.tsx → module/heroType.tsx} +14 -17
- package/templates/shopify/schemaTypes/objects/module/{imageCallToAction.tsx → imageCallToActionType.tsx} +6 -10
- package/templates/shopify/schemaTypes/objects/module/{image.ts → imageFeatureType.ts} +6 -18
- package/templates/shopify/schemaTypes/objects/module/{images.tsx → imageFeaturesType.tsx} +7 -25
- package/templates/shopify/schemaTypes/objects/module/{instagram.ts → instagramType.ts} +2 -2
- package/templates/shopify/schemaTypes/objects/module/{products.tsx → productFeaturesType.tsx} +6 -11
- package/templates/shopify/schemaTypes/objects/module/{product.tsx → productReferenceType.tsx} +6 -8
- package/templates/shopify/schemaTypes/objects/{seo/seo.ts → seoType.ts} +7 -6
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollectionRule.tsx → collectionRuleType.tsx} +2 -10
- package/templates/shopify/schemaTypes/objects/shopify/{inventory.ts → inventoryType.ts} +7 -12
- package/templates/shopify/schemaTypes/objects/shopify/{option.tsx → optionType.tsx} +6 -12
- package/templates/shopify/schemaTypes/objects/shopify/{placeholderString.ts → placeholderStringType.ts} +3 -1
- package/templates/shopify/schemaTypes/objects/shopify/{priceRange.ts → priceRangeType.ts} +5 -7
- package/templates/shopify/schemaTypes/objects/shopify/{productWithVariant.tsx → productWithVariantType.tsx} +2 -2
- package/templates/shopify/schemaTypes/objects/shopify/{proxyString.ts → proxyStringType.ts} +1 -1
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollection.ts → shopifyCollectionType.ts} +4 -25
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyProduct.ts → shopifyProductType.ts} +5 -35
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyProductVariant.ts → shopifyProductVariantType.ts} +1 -27
- package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
- package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
- package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
- package/templates/shopify/schemaTypes/singletons/{settings.ts → settingsType.ts} +7 -9
- package/templates/shopify/utils/shopifyUrls.ts +3 -3
- package/templates/shopify/utils/validateSlug.ts +3 -7
- package/lib/_chunks-cjs/index.js +0 -547
- package/lib/_chunks-cjs/index.js.map +0 -1
- package/lib/_chunks-cjs/node.js +0 -213
- package/lib/_chunks-cjs/node.js.map +0 -1
- package/lib/_chunks-cjs/stegaEncodeSourceMap.js +0 -357
- package/lib/_chunks-cjs/stegaEncodeSourceMap.js.map +0 -1
- package/lib/_chunks-es/index.js +0 -3336
- package/lib/_chunks-es/index.js.map +0 -1
- package/lib/_chunks-es/node.js +0 -216
- package/lib/_chunks-es/node.js.map +0 -1
- package/lib/_chunks-es/stegaEncodeSourceMap.js +0 -358
- package/lib/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/lib/index.cjs.mjs +0 -7
- package/templates/shopify/schemaTypes/blocks/body.tsx +0 -70
- package/templates/shopify/schemaTypes/objects/global/footer.ts +0 -57
- package/templates/shopify/schemaTypes/objects/global/linkExternal.ts +0 -52
- package/templates/shopify/schemaTypes/objects/global/linkInternal.ts +0 -65
- package/templates/shopify/schemaTypes/objects/global/links.ts +0 -16
- package/templates/shopify/schemaTypes/objects/hero/collection.tsx +0 -42
- package/templates/shopify/schemaTypes/objects/hero/page.tsx +0 -35
- package/templates/shopify/schemaTypes/objects/module/accordionBody.ts +0 -45
- package/templates/shopify/schemaTypes/objects/module/gridItem.ts +0 -91
- package/templates/shopify/schemaTypes/objects/seo/description.tsx +0 -10
- package/templates/shopify/schemaTypes/objects/seo/home.tsx +0 -31
- package/templates/shopify/schemaTypes/objects/seo/page.tsx +0 -37
- package/templates/shopify/schemaTypes/objects/seo/shopify.tsx +0 -40
- package/templates/shopify/schemaTypes/singletons/home.ts +0 -62
- /package/lib/{dts/src/index.d.ts → index.d.mts} +0 -0
package/lib/_chunks-es/index.js
DELETED
@@ -1,3336 +0,0 @@
|
|
1
|
-
import { getIt } from "get-it";
|
2
|
-
import { debug as debug$1, headers, agent, retry, jsonRequest, jsonResponse, progress, observable as observable$1 } from "get-it/middleware";
|
3
|
-
import fs$1 from "fs";
|
4
|
-
import path$1 from "path";
|
5
|
-
import "worker_threads";
|
6
|
-
import "pkg-dir";
|
7
|
-
import require$$0$1 from "tty";
|
8
|
-
import require$$1 from "util";
|
9
|
-
import require$$0 from "os";
|
10
|
-
import fs$2 from "node:fs";
|
11
|
-
import path$2 from "node:path";
|
12
|
-
import require$$3 from "crypto";
|
13
|
-
var extendStatics = function(d, b) {
|
14
|
-
return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
15
|
-
d2.__proto__ = b2;
|
16
|
-
} || function(d2, b2) {
|
17
|
-
for (var p in b2)
|
18
|
-
Object.prototype.hasOwnProperty.call(b2, p) && (d2[p] = b2[p]);
|
19
|
-
}, extendStatics(d, b);
|
20
|
-
};
|
21
|
-
function __extends(d, b) {
|
22
|
-
if (typeof b != "function" && b !== null)
|
23
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
24
|
-
extendStatics(d, b);
|
25
|
-
function __() {
|
26
|
-
this.constructor = d;
|
27
|
-
}
|
28
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
29
|
-
}
|
30
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
31
|
-
function adopt(value) {
|
32
|
-
return value instanceof P ? value : new P(function(resolve) {
|
33
|
-
resolve(value);
|
34
|
-
});
|
35
|
-
}
|
36
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
37
|
-
function fulfilled(value) {
|
38
|
-
try {
|
39
|
-
step(generator.next(value));
|
40
|
-
} catch (e) {
|
41
|
-
reject(e);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
function rejected(value) {
|
45
|
-
try {
|
46
|
-
step(generator.throw(value));
|
47
|
-
} catch (e) {
|
48
|
-
reject(e);
|
49
|
-
}
|
50
|
-
}
|
51
|
-
function step(result) {
|
52
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
53
|
-
}
|
54
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
55
|
-
});
|
56
|
-
}
|
57
|
-
function __generator(thisArg, body) {
|
58
|
-
var _ = { label: 0, sent: function() {
|
59
|
-
if (t[0] & 1)
|
60
|
-
throw t[1];
|
61
|
-
return t[1];
|
62
|
-
}, trys: [], ops: [] }, f2, y, t, g;
|
63
|
-
return g = { next: verb(0), throw: verb(1), return: verb(2) }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
64
|
-
return this;
|
65
|
-
}), g;
|
66
|
-
function verb(n) {
|
67
|
-
return function(v) {
|
68
|
-
return step([n, v]);
|
69
|
-
};
|
70
|
-
}
|
71
|
-
function step(op) {
|
72
|
-
if (f2)
|
73
|
-
throw new TypeError("Generator is already executing.");
|
74
|
-
for (; g && (g = 0, op[0] && (_ = 0)), _; )
|
75
|
-
try {
|
76
|
-
if (f2 = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
77
|
-
return t;
|
78
|
-
switch (y = 0, t && (op = [op[0] & 2, t.value]), op[0]) {
|
79
|
-
case 0:
|
80
|
-
case 1:
|
81
|
-
t = op;
|
82
|
-
break;
|
83
|
-
case 4:
|
84
|
-
return _.label++, { value: op[1], done: !1 };
|
85
|
-
case 5:
|
86
|
-
_.label++, y = op[1], op = [0];
|
87
|
-
continue;
|
88
|
-
case 7:
|
89
|
-
op = _.ops.pop(), _.trys.pop();
|
90
|
-
continue;
|
91
|
-
default:
|
92
|
-
if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
93
|
-
_ = 0;
|
94
|
-
continue;
|
95
|
-
}
|
96
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
97
|
-
_.label = op[1];
|
98
|
-
break;
|
99
|
-
}
|
100
|
-
if (op[0] === 6 && _.label < t[1]) {
|
101
|
-
_.label = t[1], t = op;
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
if (t && _.label < t[2]) {
|
105
|
-
_.label = t[2], _.ops.push(op);
|
106
|
-
break;
|
107
|
-
}
|
108
|
-
t[2] && _.ops.pop(), _.trys.pop();
|
109
|
-
continue;
|
110
|
-
}
|
111
|
-
op = body.call(thisArg, _);
|
112
|
-
} catch (e) {
|
113
|
-
op = [6, e], y = 0;
|
114
|
-
} finally {
|
115
|
-
f2 = t = 0;
|
116
|
-
}
|
117
|
-
if (op[0] & 5)
|
118
|
-
throw op[1];
|
119
|
-
return { value: op[0] ? op[1] : void 0, done: !0 };
|
120
|
-
}
|
121
|
-
}
|
122
|
-
function __values(o) {
|
123
|
-
var s2 = typeof Symbol == "function" && Symbol.iterator, m = s2 && o[s2], i = 0;
|
124
|
-
if (m)
|
125
|
-
return m.call(o);
|
126
|
-
if (o && typeof o.length == "number")
|
127
|
-
return {
|
128
|
-
next: function() {
|
129
|
-
return o && i >= o.length && (o = void 0), { value: o && o[i++], done: !o };
|
130
|
-
}
|
131
|
-
};
|
132
|
-
throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
133
|
-
}
|
134
|
-
function __read(o, n) {
|
135
|
-
var m = typeof Symbol == "function" && o[Symbol.iterator];
|
136
|
-
if (!m)
|
137
|
-
return o;
|
138
|
-
var i = m.call(o), r, ar = [], e;
|
139
|
-
try {
|
140
|
-
for (; (n === void 0 || n-- > 0) && !(r = i.next()).done; )
|
141
|
-
ar.push(r.value);
|
142
|
-
} catch (error) {
|
143
|
-
e = { error };
|
144
|
-
} finally {
|
145
|
-
try {
|
146
|
-
r && !r.done && (m = i.return) && m.call(i);
|
147
|
-
} finally {
|
148
|
-
if (e)
|
149
|
-
throw e.error;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
return ar;
|
153
|
-
}
|
154
|
-
function __spreadArray(to, from2, pack) {
|
155
|
-
if (pack || arguments.length === 2)
|
156
|
-
for (var i = 0, l = from2.length, ar; i < l; i++)
|
157
|
-
(ar || !(i in from2)) && (ar || (ar = Array.prototype.slice.call(from2, 0, i)), ar[i] = from2[i]);
|
158
|
-
return to.concat(ar || Array.prototype.slice.call(from2));
|
159
|
-
}
|
160
|
-
function __await(v) {
|
161
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
162
|
-
}
|
163
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
164
|
-
if (!Symbol.asyncIterator)
|
165
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
166
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
167
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
168
|
-
return this;
|
169
|
-
}, i;
|
170
|
-
function verb(n) {
|
171
|
-
g[n] && (i[n] = function(v) {
|
172
|
-
return new Promise(function(a, b) {
|
173
|
-
q.push([n, v, a, b]) > 1 || resume(n, v);
|
174
|
-
});
|
175
|
-
});
|
176
|
-
}
|
177
|
-
function resume(n, v) {
|
178
|
-
try {
|
179
|
-
step(g[n](v));
|
180
|
-
} catch (e) {
|
181
|
-
settle(q[0][3], e);
|
182
|
-
}
|
183
|
-
}
|
184
|
-
function step(r) {
|
185
|
-
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
186
|
-
}
|
187
|
-
function fulfill(value) {
|
188
|
-
resume("next", value);
|
189
|
-
}
|
190
|
-
function reject(value) {
|
191
|
-
resume("throw", value);
|
192
|
-
}
|
193
|
-
function settle(f2, v) {
|
194
|
-
f2(v), q.shift(), q.length && resume(q[0][0], q[0][1]);
|
195
|
-
}
|
196
|
-
}
|
197
|
-
function __asyncValues(o) {
|
198
|
-
if (!Symbol.asyncIterator)
|
199
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
200
|
-
var m = o[Symbol.asyncIterator], i;
|
201
|
-
return m ? m.call(o) : (o = typeof __values == "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
202
|
-
return this;
|
203
|
-
}, i);
|
204
|
-
function verb(n) {
|
205
|
-
i[n] = o[n] && function(v) {
|
206
|
-
return new Promise(function(resolve, reject) {
|
207
|
-
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
208
|
-
});
|
209
|
-
};
|
210
|
-
}
|
211
|
-
function settle(resolve, reject, d, v) {
|
212
|
-
Promise.resolve(v).then(function(v2) {
|
213
|
-
resolve({ value: v2, done: d });
|
214
|
-
}, reject);
|
215
|
-
}
|
216
|
-
}
|
217
|
-
function isFunction(value) {
|
218
|
-
return typeof value == "function";
|
219
|
-
}
|
220
|
-
function createErrorClass(createImpl) {
|
221
|
-
var _super = function(instance) {
|
222
|
-
Error.call(instance), instance.stack = new Error().stack;
|
223
|
-
}, ctorFunc = createImpl(_super);
|
224
|
-
return ctorFunc.prototype = Object.create(Error.prototype), ctorFunc.prototype.constructor = ctorFunc, ctorFunc;
|
225
|
-
}
|
226
|
-
var UnsubscriptionError = createErrorClass(function(_super) {
|
227
|
-
return function(errors) {
|
228
|
-
_super(this), this.message = errors ? errors.length + ` errors occurred during unsubscription:
|
229
|
-
` + errors.map(function(err, i) {
|
230
|
-
return i + 1 + ") " + err.toString();
|
231
|
-
}).join(`
|
232
|
-
`) : "", this.name = "UnsubscriptionError", this.errors = errors;
|
233
|
-
};
|
234
|
-
});
|
235
|
-
function arrRemove(arr, item) {
|
236
|
-
if (arr) {
|
237
|
-
var index = arr.indexOf(item);
|
238
|
-
0 <= index && arr.splice(index, 1);
|
239
|
-
}
|
240
|
-
}
|
241
|
-
var Subscription = function() {
|
242
|
-
function Subscription2(initialTeardown) {
|
243
|
-
this.initialTeardown = initialTeardown, this.closed = !1, this._parentage = null, this._finalizers = null;
|
244
|
-
}
|
245
|
-
return Subscription2.prototype.unsubscribe = function() {
|
246
|
-
var e_1, _a, e_2, _b, errors;
|
247
|
-
if (!this.closed) {
|
248
|
-
this.closed = !0;
|
249
|
-
var _parentage = this._parentage;
|
250
|
-
if (_parentage)
|
251
|
-
if (this._parentage = null, Array.isArray(_parentage))
|
252
|
-
try {
|
253
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
254
|
-
var parent_1 = _parentage_1_1.value;
|
255
|
-
parent_1.remove(this);
|
256
|
-
}
|
257
|
-
} catch (e_1_1) {
|
258
|
-
e_1 = { error: e_1_1 };
|
259
|
-
} finally {
|
260
|
-
try {
|
261
|
-
_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return) && _a.call(_parentage_1);
|
262
|
-
} finally {
|
263
|
-
if (e_1)
|
264
|
-
throw e_1.error;
|
265
|
-
}
|
266
|
-
}
|
267
|
-
else
|
268
|
-
_parentage.remove(this);
|
269
|
-
var initialFinalizer = this.initialTeardown;
|
270
|
-
if (isFunction(initialFinalizer))
|
271
|
-
try {
|
272
|
-
initialFinalizer();
|
273
|
-
} catch (e) {
|
274
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
275
|
-
}
|
276
|
-
var _finalizers = this._finalizers;
|
277
|
-
if (_finalizers) {
|
278
|
-
this._finalizers = null;
|
279
|
-
try {
|
280
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
281
|
-
var finalizer = _finalizers_1_1.value;
|
282
|
-
try {
|
283
|
-
execFinalizer(finalizer);
|
284
|
-
} catch (err) {
|
285
|
-
errors = errors ?? [], err instanceof UnsubscriptionError ? errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors)) : errors.push(err);
|
286
|
-
}
|
287
|
-
}
|
288
|
-
} catch (e_2_1) {
|
289
|
-
e_2 = { error: e_2_1 };
|
290
|
-
} finally {
|
291
|
-
try {
|
292
|
-
_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return) && _b.call(_finalizers_1);
|
293
|
-
} finally {
|
294
|
-
if (e_2)
|
295
|
-
throw e_2.error;
|
296
|
-
}
|
297
|
-
}
|
298
|
-
}
|
299
|
-
if (errors)
|
300
|
-
throw new UnsubscriptionError(errors);
|
301
|
-
}
|
302
|
-
}, Subscription2.prototype.add = function(teardown) {
|
303
|
-
var _a;
|
304
|
-
if (teardown && teardown !== this)
|
305
|
-
if (this.closed)
|
306
|
-
execFinalizer(teardown);
|
307
|
-
else {
|
308
|
-
if (teardown instanceof Subscription2) {
|
309
|
-
if (teardown.closed || teardown._hasParent(this))
|
310
|
-
return;
|
311
|
-
teardown._addParent(this);
|
312
|
-
}
|
313
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
314
|
-
}
|
315
|
-
}, Subscription2.prototype._hasParent = function(parent) {
|
316
|
-
var _parentage = this._parentage;
|
317
|
-
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
318
|
-
}, Subscription2.prototype._addParent = function(parent) {
|
319
|
-
var _parentage = this._parentage;
|
320
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
321
|
-
}, Subscription2.prototype._removeParent = function(parent) {
|
322
|
-
var _parentage = this._parentage;
|
323
|
-
_parentage === parent ? this._parentage = null : Array.isArray(_parentage) && arrRemove(_parentage, parent);
|
324
|
-
}, Subscription2.prototype.remove = function(teardown) {
|
325
|
-
var _finalizers = this._finalizers;
|
326
|
-
_finalizers && arrRemove(_finalizers, teardown), teardown instanceof Subscription2 && teardown._removeParent(this);
|
327
|
-
}, Subscription2.EMPTY = function() {
|
328
|
-
var empty = new Subscription2();
|
329
|
-
return empty.closed = !0, empty;
|
330
|
-
}(), Subscription2;
|
331
|
-
}();
|
332
|
-
function isSubscription(value) {
|
333
|
-
return value instanceof Subscription || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
|
334
|
-
}
|
335
|
-
function execFinalizer(finalizer) {
|
336
|
-
isFunction(finalizer) ? finalizer() : finalizer.unsubscribe();
|
337
|
-
}
|
338
|
-
var config$1 = {
|
339
|
-
onUnhandledError: null,
|
340
|
-
onStoppedNotification: null,
|
341
|
-
Promise: void 0,
|
342
|
-
useDeprecatedSynchronousErrorHandling: !1,
|
343
|
-
useDeprecatedNextContext: !1
|
344
|
-
}, timeoutProvider = {
|
345
|
-
setTimeout: function(handler, timeout) {
|
346
|
-
for (var args = [], _i = 2; _i < arguments.length; _i++)
|
347
|
-
args[_i - 2] = arguments[_i];
|
348
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
349
|
-
},
|
350
|
-
clearTimeout: function(handle) {
|
351
|
-
return clearTimeout(handle);
|
352
|
-
},
|
353
|
-
delegate: void 0
|
354
|
-
};
|
355
|
-
function reportUnhandledError(err) {
|
356
|
-
timeoutProvider.setTimeout(function() {
|
357
|
-
throw err;
|
358
|
-
});
|
359
|
-
}
|
360
|
-
function noop() {
|
361
|
-
}
|
362
|
-
function errorContext(cb) {
|
363
|
-
cb();
|
364
|
-
}
|
365
|
-
var Subscriber = function(_super) {
|
366
|
-
__extends(Subscriber2, _super);
|
367
|
-
function Subscriber2(destination) {
|
368
|
-
var _this = _super.call(this) || this;
|
369
|
-
return _this.isStopped = !1, destination ? (_this.destination = destination, isSubscription(destination) && destination.add(_this)) : _this.destination = EMPTY_OBSERVER, _this;
|
370
|
-
}
|
371
|
-
return Subscriber2.create = function(next, error, complete) {
|
372
|
-
return new SafeSubscriber(next, error, complete);
|
373
|
-
}, Subscriber2.prototype.next = function(value) {
|
374
|
-
this.isStopped || this._next(value);
|
375
|
-
}, Subscriber2.prototype.error = function(err) {
|
376
|
-
this.isStopped || (this.isStopped = !0, this._error(err));
|
377
|
-
}, Subscriber2.prototype.complete = function() {
|
378
|
-
this.isStopped || (this.isStopped = !0, this._complete());
|
379
|
-
}, Subscriber2.prototype.unsubscribe = function() {
|
380
|
-
this.closed || (this.isStopped = !0, _super.prototype.unsubscribe.call(this), this.destination = null);
|
381
|
-
}, Subscriber2.prototype._next = function(value) {
|
382
|
-
this.destination.next(value);
|
383
|
-
}, Subscriber2.prototype._error = function(err) {
|
384
|
-
try {
|
385
|
-
this.destination.error(err);
|
386
|
-
} finally {
|
387
|
-
this.unsubscribe();
|
388
|
-
}
|
389
|
-
}, Subscriber2.prototype._complete = function() {
|
390
|
-
try {
|
391
|
-
this.destination.complete();
|
392
|
-
} finally {
|
393
|
-
this.unsubscribe();
|
394
|
-
}
|
395
|
-
}, Subscriber2;
|
396
|
-
}(Subscription), _bind = Function.prototype.bind;
|
397
|
-
function bind(fn, thisArg) {
|
398
|
-
return _bind.call(fn, thisArg);
|
399
|
-
}
|
400
|
-
var ConsumerObserver = function() {
|
401
|
-
function ConsumerObserver2(partialObserver) {
|
402
|
-
this.partialObserver = partialObserver;
|
403
|
-
}
|
404
|
-
return ConsumerObserver2.prototype.next = function(value) {
|
405
|
-
var partialObserver = this.partialObserver;
|
406
|
-
if (partialObserver.next)
|
407
|
-
try {
|
408
|
-
partialObserver.next(value);
|
409
|
-
} catch (error) {
|
410
|
-
handleUnhandledError(error);
|
411
|
-
}
|
412
|
-
}, ConsumerObserver2.prototype.error = function(err) {
|
413
|
-
var partialObserver = this.partialObserver;
|
414
|
-
if (partialObserver.error)
|
415
|
-
try {
|
416
|
-
partialObserver.error(err);
|
417
|
-
} catch (error) {
|
418
|
-
handleUnhandledError(error);
|
419
|
-
}
|
420
|
-
else
|
421
|
-
handleUnhandledError(err);
|
422
|
-
}, ConsumerObserver2.prototype.complete = function() {
|
423
|
-
var partialObserver = this.partialObserver;
|
424
|
-
if (partialObserver.complete)
|
425
|
-
try {
|
426
|
-
partialObserver.complete();
|
427
|
-
} catch (error) {
|
428
|
-
handleUnhandledError(error);
|
429
|
-
}
|
430
|
-
}, ConsumerObserver2;
|
431
|
-
}(), SafeSubscriber = function(_super) {
|
432
|
-
__extends(SafeSubscriber2, _super);
|
433
|
-
function SafeSubscriber2(observerOrNext, error, complete) {
|
434
|
-
var _this = _super.call(this) || this, partialObserver;
|
435
|
-
if (isFunction(observerOrNext) || !observerOrNext)
|
436
|
-
partialObserver = {
|
437
|
-
next: observerOrNext ?? void 0,
|
438
|
-
error: error ?? void 0,
|
439
|
-
complete: complete ?? void 0
|
440
|
-
};
|
441
|
-
else {
|
442
|
-
var context_1;
|
443
|
-
_this && config$1.useDeprecatedNextContext ? (context_1 = Object.create(observerOrNext), context_1.unsubscribe = function() {
|
444
|
-
return _this.unsubscribe();
|
445
|
-
}, partialObserver = {
|
446
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
447
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
448
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1)
|
449
|
-
}) : partialObserver = observerOrNext;
|
450
|
-
}
|
451
|
-
return _this.destination = new ConsumerObserver(partialObserver), _this;
|
452
|
-
}
|
453
|
-
return SafeSubscriber2;
|
454
|
-
}(Subscriber);
|
455
|
-
function handleUnhandledError(error) {
|
456
|
-
reportUnhandledError(error);
|
457
|
-
}
|
458
|
-
function defaultErrorHandler(err) {
|
459
|
-
throw err;
|
460
|
-
}
|
461
|
-
var EMPTY_OBSERVER = {
|
462
|
-
closed: !0,
|
463
|
-
next: noop,
|
464
|
-
error: defaultErrorHandler,
|
465
|
-
complete: noop
|
466
|
-
}, observable = function() {
|
467
|
-
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
468
|
-
}();
|
469
|
-
function identity(x) {
|
470
|
-
return x;
|
471
|
-
}
|
472
|
-
function pipe() {
|
473
|
-
for (var fns = [], _i = 0; _i < arguments.length; _i++)
|
474
|
-
fns[_i] = arguments[_i];
|
475
|
-
return pipeFromArray(fns);
|
476
|
-
}
|
477
|
-
function pipeFromArray(fns) {
|
478
|
-
return fns.length === 0 ? identity : fns.length === 1 ? fns[0] : function(input) {
|
479
|
-
return fns.reduce(function(prev, fn) {
|
480
|
-
return fn(prev);
|
481
|
-
}, input);
|
482
|
-
};
|
483
|
-
}
|
484
|
-
var Observable = function() {
|
485
|
-
function Observable2(subscribe) {
|
486
|
-
subscribe && (this._subscribe = subscribe);
|
487
|
-
}
|
488
|
-
return Observable2.prototype.lift = function(operator) {
|
489
|
-
var observable2 = new Observable2();
|
490
|
-
return observable2.source = this, observable2.operator = operator, observable2;
|
491
|
-
}, Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
|
492
|
-
var _this = this, subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
493
|
-
return errorContext(function() {
|
494
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
495
|
-
subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
|
496
|
-
}), subscriber;
|
497
|
-
}, Observable2.prototype._trySubscribe = function(sink) {
|
498
|
-
try {
|
499
|
-
return this._subscribe(sink);
|
500
|
-
} catch (err) {
|
501
|
-
sink.error(err);
|
502
|
-
}
|
503
|
-
}, Observable2.prototype.forEach = function(next, promiseCtor) {
|
504
|
-
var _this = this;
|
505
|
-
return promiseCtor = getPromiseCtor(promiseCtor), new promiseCtor(function(resolve, reject) {
|
506
|
-
var subscriber = new SafeSubscriber({
|
507
|
-
next: function(value) {
|
508
|
-
try {
|
509
|
-
next(value);
|
510
|
-
} catch (err) {
|
511
|
-
reject(err), subscriber.unsubscribe();
|
512
|
-
}
|
513
|
-
},
|
514
|
-
error: reject,
|
515
|
-
complete: resolve
|
516
|
-
});
|
517
|
-
_this.subscribe(subscriber);
|
518
|
-
});
|
519
|
-
}, Observable2.prototype._subscribe = function(subscriber) {
|
520
|
-
var _a;
|
521
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
522
|
-
}, Observable2.prototype[observable] = function() {
|
523
|
-
return this;
|
524
|
-
}, Observable2.prototype.pipe = function() {
|
525
|
-
for (var operations = [], _i = 0; _i < arguments.length; _i++)
|
526
|
-
operations[_i] = arguments[_i];
|
527
|
-
return pipeFromArray(operations)(this);
|
528
|
-
}, Observable2.prototype.toPromise = function(promiseCtor) {
|
529
|
-
var _this = this;
|
530
|
-
return promiseCtor = getPromiseCtor(promiseCtor), new promiseCtor(function(resolve, reject) {
|
531
|
-
var value;
|
532
|
-
_this.subscribe(function(x) {
|
533
|
-
return value = x;
|
534
|
-
}, function(err) {
|
535
|
-
return reject(err);
|
536
|
-
}, function() {
|
537
|
-
return resolve(value);
|
538
|
-
});
|
539
|
-
});
|
540
|
-
}, Observable2.create = function(subscribe) {
|
541
|
-
return new Observable2(subscribe);
|
542
|
-
}, Observable2;
|
543
|
-
}();
|
544
|
-
function getPromiseCtor(promiseCtor) {
|
545
|
-
var _a;
|
546
|
-
return (_a = promiseCtor ?? config$1.Promise) !== null && _a !== void 0 ? _a : Promise;
|
547
|
-
}
|
548
|
-
function isObserver(value) {
|
549
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
550
|
-
}
|
551
|
-
function isSubscriber(value) {
|
552
|
-
return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
|
553
|
-
}
|
554
|
-
function hasLift(source) {
|
555
|
-
return isFunction(source?.lift);
|
556
|
-
}
|
557
|
-
function operate(init) {
|
558
|
-
return function(source) {
|
559
|
-
if (hasLift(source))
|
560
|
-
return source.lift(function(liftedSource) {
|
561
|
-
try {
|
562
|
-
return init(liftedSource, this);
|
563
|
-
} catch (err) {
|
564
|
-
this.error(err);
|
565
|
-
}
|
566
|
-
});
|
567
|
-
throw new TypeError("Unable to lift unknown Observable type");
|
568
|
-
};
|
569
|
-
}
|
570
|
-
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
571
|
-
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
572
|
-
}
|
573
|
-
var OperatorSubscriber = function(_super) {
|
574
|
-
__extends(OperatorSubscriber2, _super);
|
575
|
-
function OperatorSubscriber2(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
576
|
-
var _this = _super.call(this, destination) || this;
|
577
|
-
return _this.onFinalize = onFinalize, _this.shouldUnsubscribe = shouldUnsubscribe, _this._next = onNext ? function(value) {
|
578
|
-
try {
|
579
|
-
onNext(value);
|
580
|
-
} catch (err) {
|
581
|
-
destination.error(err);
|
582
|
-
}
|
583
|
-
} : _super.prototype._next, _this._error = onError ? function(err) {
|
584
|
-
try {
|
585
|
-
onError(err);
|
586
|
-
} catch (err2) {
|
587
|
-
destination.error(err2);
|
588
|
-
} finally {
|
589
|
-
this.unsubscribe();
|
590
|
-
}
|
591
|
-
} : _super.prototype._error, _this._complete = onComplete ? function() {
|
592
|
-
try {
|
593
|
-
onComplete();
|
594
|
-
} catch (err) {
|
595
|
-
destination.error(err);
|
596
|
-
} finally {
|
597
|
-
this.unsubscribe();
|
598
|
-
}
|
599
|
-
} : _super.prototype._complete, _this;
|
600
|
-
}
|
601
|
-
return OperatorSubscriber2.prototype.unsubscribe = function() {
|
602
|
-
var _a;
|
603
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
604
|
-
var closed_1 = this.closed;
|
605
|
-
_super.prototype.unsubscribe.call(this), !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 || _a.call(this));
|
606
|
-
}
|
607
|
-
}, OperatorSubscriber2;
|
608
|
-
}(Subscriber);
|
609
|
-
function last(arr) {
|
610
|
-
return arr[arr.length - 1];
|
611
|
-
}
|
612
|
-
function popResultSelector(args) {
|
613
|
-
return isFunction(last(args)) ? args.pop() : void 0;
|
614
|
-
}
|
615
|
-
var isArrayLike = function(x) {
|
616
|
-
return x && typeof x.length == "number" && typeof x != "function";
|
617
|
-
};
|
618
|
-
function isPromise(value) {
|
619
|
-
return isFunction(value?.then);
|
620
|
-
}
|
621
|
-
function isInteropObservable(input) {
|
622
|
-
return isFunction(input[observable]);
|
623
|
-
}
|
624
|
-
function isAsyncIterable(obj) {
|
625
|
-
return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);
|
626
|
-
}
|
627
|
-
function createInvalidObservableTypeError(input) {
|
628
|
-
return new TypeError("You provided " + (input !== null && typeof input == "object" ? "an invalid object" : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
629
|
-
}
|
630
|
-
function getSymbolIterator() {
|
631
|
-
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
632
|
-
}
|
633
|
-
var iterator = getSymbolIterator();
|
634
|
-
function isIterable(input) {
|
635
|
-
return isFunction(input?.[iterator]);
|
636
|
-
}
|
637
|
-
function readableStreamLikeToAsyncGenerator(readableStream) {
|
638
|
-
return __asyncGenerator(this, arguments, function() {
|
639
|
-
var reader, _a, value, done;
|
640
|
-
return __generator(this, function(_b) {
|
641
|
-
switch (_b.label) {
|
642
|
-
case 0:
|
643
|
-
reader = readableStream.getReader(), _b.label = 1;
|
644
|
-
case 1:
|
645
|
-
_b.trys.push([1, , 9, 10]), _b.label = 2;
|
646
|
-
case 2:
|
647
|
-
return [4, __await(reader.read())];
|
648
|
-
case 3:
|
649
|
-
return _a = _b.sent(), value = _a.value, done = _a.done, done ? [4, __await(void 0)] : [3, 5];
|
650
|
-
case 4:
|
651
|
-
return [2, _b.sent()];
|
652
|
-
case 5:
|
653
|
-
return [4, __await(value)];
|
654
|
-
case 6:
|
655
|
-
return [4, _b.sent()];
|
656
|
-
case 7:
|
657
|
-
return _b.sent(), [3, 2];
|
658
|
-
case 8:
|
659
|
-
return [3, 10];
|
660
|
-
case 9:
|
661
|
-
return reader.releaseLock(), [7];
|
662
|
-
case 10:
|
663
|
-
return [2];
|
664
|
-
}
|
665
|
-
});
|
666
|
-
});
|
667
|
-
}
|
668
|
-
function isReadableStreamLike(obj) {
|
669
|
-
return isFunction(obj?.getReader);
|
670
|
-
}
|
671
|
-
function innerFrom(input) {
|
672
|
-
if (input instanceof Observable)
|
673
|
-
return input;
|
674
|
-
if (input != null) {
|
675
|
-
if (isInteropObservable(input))
|
676
|
-
return fromInteropObservable(input);
|
677
|
-
if (isArrayLike(input))
|
678
|
-
return fromArrayLike(input);
|
679
|
-
if (isPromise(input))
|
680
|
-
return fromPromise(input);
|
681
|
-
if (isAsyncIterable(input))
|
682
|
-
return fromAsyncIterable(input);
|
683
|
-
if (isIterable(input))
|
684
|
-
return fromIterable(input);
|
685
|
-
if (isReadableStreamLike(input))
|
686
|
-
return fromReadableStreamLike(input);
|
687
|
-
}
|
688
|
-
throw createInvalidObservableTypeError(input);
|
689
|
-
}
|
690
|
-
function fromInteropObservable(obj) {
|
691
|
-
return new Observable(function(subscriber) {
|
692
|
-
var obs = obj[observable]();
|
693
|
-
if (isFunction(obs.subscribe))
|
694
|
-
return obs.subscribe(subscriber);
|
695
|
-
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
696
|
-
});
|
697
|
-
}
|
698
|
-
function fromArrayLike(array) {
|
699
|
-
return new Observable(function(subscriber) {
|
700
|
-
for (var i = 0; i < array.length && !subscriber.closed; i++)
|
701
|
-
subscriber.next(array[i]);
|
702
|
-
subscriber.complete();
|
703
|
-
});
|
704
|
-
}
|
705
|
-
function fromPromise(promise) {
|
706
|
-
return new Observable(function(subscriber) {
|
707
|
-
promise.then(function(value) {
|
708
|
-
subscriber.closed || (subscriber.next(value), subscriber.complete());
|
709
|
-
}, function(err) {
|
710
|
-
return subscriber.error(err);
|
711
|
-
}).then(null, reportUnhandledError);
|
712
|
-
});
|
713
|
-
}
|
714
|
-
function fromIterable(iterable) {
|
715
|
-
return new Observable(function(subscriber) {
|
716
|
-
var e_1, _a;
|
717
|
-
try {
|
718
|
-
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
719
|
-
var value = iterable_1_1.value;
|
720
|
-
if (subscriber.next(value), subscriber.closed)
|
721
|
-
return;
|
722
|
-
}
|
723
|
-
} catch (e_1_1) {
|
724
|
-
e_1 = { error: e_1_1 };
|
725
|
-
} finally {
|
726
|
-
try {
|
727
|
-
iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return) && _a.call(iterable_1);
|
728
|
-
} finally {
|
729
|
-
if (e_1)
|
730
|
-
throw e_1.error;
|
731
|
-
}
|
732
|
-
}
|
733
|
-
subscriber.complete();
|
734
|
-
});
|
735
|
-
}
|
736
|
-
function fromAsyncIterable(asyncIterable) {
|
737
|
-
return new Observable(function(subscriber) {
|
738
|
-
process$1(asyncIterable, subscriber).catch(function(err) {
|
739
|
-
return subscriber.error(err);
|
740
|
-
});
|
741
|
-
});
|
742
|
-
}
|
743
|
-
function fromReadableStreamLike(readableStream) {
|
744
|
-
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
745
|
-
}
|
746
|
-
function process$1(asyncIterable, subscriber) {
|
747
|
-
var asyncIterable_1, asyncIterable_1_1, e_2, _a;
|
748
|
-
return __awaiter(this, void 0, void 0, function() {
|
749
|
-
var value, e_2_1;
|
750
|
-
return __generator(this, function(_b) {
|
751
|
-
switch (_b.label) {
|
752
|
-
case 0:
|
753
|
-
_b.trys.push([0, 5, 6, 11]), asyncIterable_1 = __asyncValues(asyncIterable), _b.label = 1;
|
754
|
-
case 1:
|
755
|
-
return [4, asyncIterable_1.next()];
|
756
|
-
case 2:
|
757
|
-
if (asyncIterable_1_1 = _b.sent(), !!asyncIterable_1_1.done)
|
758
|
-
return [3, 4];
|
759
|
-
if (value = asyncIterable_1_1.value, subscriber.next(value), subscriber.closed)
|
760
|
-
return [2];
|
761
|
-
_b.label = 3;
|
762
|
-
case 3:
|
763
|
-
return [3, 1];
|
764
|
-
case 4:
|
765
|
-
return [3, 11];
|
766
|
-
case 5:
|
767
|
-
return e_2_1 = _b.sent(), e_2 = { error: e_2_1 }, [3, 11];
|
768
|
-
case 6:
|
769
|
-
return _b.trys.push([6, , 9, 10]), asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return) ? [4, _a.call(asyncIterable_1)] : [3, 8];
|
770
|
-
case 7:
|
771
|
-
_b.sent(), _b.label = 8;
|
772
|
-
case 8:
|
773
|
-
return [3, 10];
|
774
|
-
case 9:
|
775
|
-
if (e_2)
|
776
|
-
throw e_2.error;
|
777
|
-
return [7];
|
778
|
-
case 10:
|
779
|
-
return [7];
|
780
|
-
case 11:
|
781
|
-
return subscriber.complete(), [2];
|
782
|
-
}
|
783
|
-
});
|
784
|
-
});
|
785
|
-
}
|
786
|
-
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
787
|
-
delay === void 0 && (delay = 0), repeat === void 0 && (repeat = !1);
|
788
|
-
var scheduleSubscription = scheduler.schedule(function() {
|
789
|
-
work(), repeat ? parentSubscription.add(this.schedule(null, delay)) : this.unsubscribe();
|
790
|
-
}, delay);
|
791
|
-
if (parentSubscription.add(scheduleSubscription), !repeat)
|
792
|
-
return scheduleSubscription;
|
793
|
-
}
|
794
|
-
function observeOn(scheduler, delay) {
|
795
|
-
return delay === void 0 && (delay = 0), operate(function(source, subscriber) {
|
796
|
-
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
797
|
-
return executeSchedule(subscriber, scheduler, function() {
|
798
|
-
return subscriber.next(value);
|
799
|
-
}, delay);
|
800
|
-
}, function() {
|
801
|
-
return executeSchedule(subscriber, scheduler, function() {
|
802
|
-
return subscriber.complete();
|
803
|
-
}, delay);
|
804
|
-
}, function(err) {
|
805
|
-
return executeSchedule(subscriber, scheduler, function() {
|
806
|
-
return subscriber.error(err);
|
807
|
-
}, delay);
|
808
|
-
}));
|
809
|
-
});
|
810
|
-
}
|
811
|
-
function subscribeOn(scheduler, delay) {
|
812
|
-
return delay === void 0 && (delay = 0), operate(function(source, subscriber) {
|
813
|
-
subscriber.add(scheduler.schedule(function() {
|
814
|
-
return source.subscribe(subscriber);
|
815
|
-
}, delay));
|
816
|
-
});
|
817
|
-
}
|
818
|
-
function scheduleObservable(input, scheduler) {
|
819
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
820
|
-
}
|
821
|
-
function schedulePromise(input, scheduler) {
|
822
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
823
|
-
}
|
824
|
-
function scheduleArray(input, scheduler) {
|
825
|
-
return new Observable(function(subscriber) {
|
826
|
-
var i = 0;
|
827
|
-
return scheduler.schedule(function() {
|
828
|
-
i === input.length ? subscriber.complete() : (subscriber.next(input[i++]), subscriber.closed || this.schedule());
|
829
|
-
});
|
830
|
-
});
|
831
|
-
}
|
832
|
-
function scheduleIterable(input, scheduler) {
|
833
|
-
return new Observable(function(subscriber) {
|
834
|
-
var iterator$1;
|
835
|
-
return executeSchedule(subscriber, scheduler, function() {
|
836
|
-
iterator$1 = input[iterator](), executeSchedule(subscriber, scheduler, function() {
|
837
|
-
var _a, value, done;
|
838
|
-
try {
|
839
|
-
_a = iterator$1.next(), value = _a.value, done = _a.done;
|
840
|
-
} catch (err) {
|
841
|
-
subscriber.error(err);
|
842
|
-
return;
|
843
|
-
}
|
844
|
-
done ? subscriber.complete() : subscriber.next(value);
|
845
|
-
}, 0, !0);
|
846
|
-
}), function() {
|
847
|
-
return isFunction(iterator$1?.return) && iterator$1.return();
|
848
|
-
};
|
849
|
-
});
|
850
|
-
}
|
851
|
-
function scheduleAsyncIterable(input, scheduler) {
|
852
|
-
if (!input)
|
853
|
-
throw new Error("Iterable cannot be null");
|
854
|
-
return new Observable(function(subscriber) {
|
855
|
-
executeSchedule(subscriber, scheduler, function() {
|
856
|
-
var iterator2 = input[Symbol.asyncIterator]();
|
857
|
-
executeSchedule(subscriber, scheduler, function() {
|
858
|
-
iterator2.next().then(function(result) {
|
859
|
-
result.done ? subscriber.complete() : subscriber.next(result.value);
|
860
|
-
});
|
861
|
-
}, 0, !0);
|
862
|
-
});
|
863
|
-
});
|
864
|
-
}
|
865
|
-
function scheduleReadableStreamLike(input, scheduler) {
|
866
|
-
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
867
|
-
}
|
868
|
-
function scheduled(input, scheduler) {
|
869
|
-
if (input != null) {
|
870
|
-
if (isInteropObservable(input))
|
871
|
-
return scheduleObservable(input, scheduler);
|
872
|
-
if (isArrayLike(input))
|
873
|
-
return scheduleArray(input, scheduler);
|
874
|
-
if (isPromise(input))
|
875
|
-
return schedulePromise(input, scheduler);
|
876
|
-
if (isAsyncIterable(input))
|
877
|
-
return scheduleAsyncIterable(input, scheduler);
|
878
|
-
if (isIterable(input))
|
879
|
-
return scheduleIterable(input, scheduler);
|
880
|
-
if (isReadableStreamLike(input))
|
881
|
-
return scheduleReadableStreamLike(input, scheduler);
|
882
|
-
}
|
883
|
-
throw createInvalidObservableTypeError(input);
|
884
|
-
}
|
885
|
-
function from(input, scheduler) {
|
886
|
-
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
887
|
-
}
|
888
|
-
var EmptyError = createErrorClass(function(_super) {
|
889
|
-
return function() {
|
890
|
-
_super(this), this.name = "EmptyError", this.message = "no elements in sequence";
|
891
|
-
};
|
892
|
-
});
|
893
|
-
function lastValueFrom(source, config2) {
|
894
|
-
var hasConfig = typeof config2 == "object";
|
895
|
-
return new Promise(function(resolve, reject) {
|
896
|
-
var _hasValue = !1, _value;
|
897
|
-
source.subscribe({
|
898
|
-
next: function(value) {
|
899
|
-
_value = value, _hasValue = !0;
|
900
|
-
},
|
901
|
-
error: reject,
|
902
|
-
complete: function() {
|
903
|
-
_hasValue ? resolve(_value) : hasConfig ? resolve(config2.defaultValue) : reject(new EmptyError());
|
904
|
-
}
|
905
|
-
});
|
906
|
-
});
|
907
|
-
}
|
908
|
-
function map(project, thisArg) {
|
909
|
-
return operate(function(source, subscriber) {
|
910
|
-
var index = 0;
|
911
|
-
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
912
|
-
subscriber.next(project.call(thisArg, value, index++));
|
913
|
-
}));
|
914
|
-
});
|
915
|
-
}
|
916
|
-
var isArray$1 = Array.isArray;
|
917
|
-
function callOrApply(fn, args) {
|
918
|
-
return isArray$1(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args);
|
919
|
-
}
|
920
|
-
function mapOneOrManyArgs(fn) {
|
921
|
-
return map(function(args) {
|
922
|
-
return callOrApply(fn, args);
|
923
|
-
});
|
924
|
-
}
|
925
|
-
function combineLatestInit(observables, scheduler, valueTransform) {
|
926
|
-
return valueTransform === void 0 && (valueTransform = identity), function(subscriber) {
|
927
|
-
maybeSchedule(scheduler, function() {
|
928
|
-
for (var length = observables.length, values = new Array(length), active = length, remainingFirstValues = length, _loop_1 = function(i2) {
|
929
|
-
maybeSchedule(scheduler, function() {
|
930
|
-
var source = from(observables[i2], scheduler), hasFirstValue = !1;
|
931
|
-
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
932
|
-
values[i2] = value, hasFirstValue || (hasFirstValue = !0, remainingFirstValues--), remainingFirstValues || subscriber.next(valueTransform(values.slice()));
|
933
|
-
}, function() {
|
934
|
-
--active || subscriber.complete();
|
935
|
-
}));
|
936
|
-
}, subscriber);
|
937
|
-
}, i = 0; i < length; i++)
|
938
|
-
_loop_1(i);
|
939
|
-
}, subscriber);
|
940
|
-
};
|
941
|
-
}
|
942
|
-
function maybeSchedule(scheduler, execute, subscription) {
|
943
|
-
scheduler ? executeSchedule(subscription, scheduler, execute) : execute();
|
944
|
-
}
|
945
|
-
var isArray = Array.isArray;
|
946
|
-
function argsOrArgArray(args) {
|
947
|
-
return args.length === 1 && isArray(args[0]) ? args[0] : args;
|
948
|
-
}
|
949
|
-
function filter(predicate, thisArg) {
|
950
|
-
return operate(function(source, subscriber) {
|
951
|
-
var index = 0;
|
952
|
-
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
953
|
-
return predicate.call(thisArg, value, index++) && subscriber.next(value);
|
954
|
-
}));
|
955
|
-
});
|
956
|
-
}
|
957
|
-
function combineLatest() {
|
958
|
-
for (var args = [], _i = 0; _i < arguments.length; _i++)
|
959
|
-
args[_i] = arguments[_i];
|
960
|
-
var resultSelector = popResultSelector(args);
|
961
|
-
return resultSelector ? pipe(combineLatest.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector)) : operate(function(source, subscriber) {
|
962
|
-
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
|
963
|
-
});
|
964
|
-
}
|
965
|
-
function combineLatestWith() {
|
966
|
-
for (var otherSources = [], _i = 0; _i < arguments.length; _i++)
|
967
|
-
otherSources[_i] = arguments[_i];
|
968
|
-
return combineLatest.apply(void 0, __spreadArray([], __read(otherSources)));
|
969
|
-
}
|
970
|
-
class ClientError extends Error {
|
971
|
-
constructor(res) {
|
972
|
-
const props = extractErrorProps(res);
|
973
|
-
super(props.message), this.statusCode = 400, Object.assign(this, props);
|
974
|
-
}
|
975
|
-
}
|
976
|
-
class ServerError extends Error {
|
977
|
-
constructor(res) {
|
978
|
-
const props = extractErrorProps(res);
|
979
|
-
super(props.message), this.statusCode = 500, Object.assign(this, props);
|
980
|
-
}
|
981
|
-
}
|
982
|
-
function extractErrorProps(res) {
|
983
|
-
const body = res.body, props = {
|
984
|
-
response: res,
|
985
|
-
statusCode: res.statusCode,
|
986
|
-
responseBody: stringifyBody(body, res),
|
987
|
-
message: "",
|
988
|
-
details: void 0
|
989
|
-
};
|
990
|
-
if (body.error && body.message)
|
991
|
-
return props.message = `${body.error} - ${body.message}`, props;
|
992
|
-
if (isMutationError(body)) {
|
993
|
-
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
|
994
|
-
var _a;
|
995
|
-
return (_a = item.error) == null ? void 0 : _a.description;
|
996
|
-
}).filter(Boolean);
|
997
|
-
let itemsStr = items.length ? `:
|
998
|
-
- ${items.join(`
|
999
|
-
- `)}` : "";
|
1000
|
-
return allItems.length > 5 && (itemsStr += `
|
1001
|
-
...and ${allItems.length - 5} more`), props.message = `${body.error.description}${itemsStr}`, props.details = body.error, props;
|
1002
|
-
}
|
1003
|
-
return body.error && body.error.description ? (props.message = body.error.description, props.details = body.error, props) : (props.message = body.error || body.message || httpErrorMessage(res), props);
|
1004
|
-
}
|
1005
|
-
function isMutationError(body) {
|
1006
|
-
return isPlainObject(body) && isPlainObject(body.error) && body.error.type === "mutationError" && typeof body.error.description == "string";
|
1007
|
-
}
|
1008
|
-
function isPlainObject(obj) {
|
1009
|
-
return typeof obj == "object" && obj !== null && !Array.isArray(obj);
|
1010
|
-
}
|
1011
|
-
function httpErrorMessage(res) {
|
1012
|
-
const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : "";
|
1013
|
-
return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}`;
|
1014
|
-
}
|
1015
|
-
function stringifyBody(body, res) {
|
1016
|
-
return (res.headers["content-type"] || "").toLowerCase().indexOf("application/json") !== -1 ? JSON.stringify(body, null, 2) : body;
|
1017
|
-
}
|
1018
|
-
const httpError = {
|
1019
|
-
onResponse: (res) => {
|
1020
|
-
if (res.statusCode >= 500)
|
1021
|
-
throw new ServerError(res);
|
1022
|
-
if (res.statusCode >= 400)
|
1023
|
-
throw new ClientError(res);
|
1024
|
-
return res;
|
1025
|
-
}
|
1026
|
-
}, printWarnings = {
|
1027
|
-
onResponse: (res) => {
|
1028
|
-
const warn2 = res.headers["x-sanity-warning"];
|
1029
|
-
return (Array.isArray(warn2) ? warn2 : [warn2]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
1030
|
-
}
|
1031
|
-
};
|
1032
|
-
function defineHttpRequest(envMiddleware, {
|
1033
|
-
maxRetries = 5,
|
1034
|
-
retryDelay
|
1035
|
-
}) {
|
1036
|
-
const request = getIt([
|
1037
|
-
maxRetries > 0 ? retry({
|
1038
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1039
|
-
retryDelay,
|
1040
|
-
// This option is typed incorrectly in get-it.
|
1041
|
-
maxRetries,
|
1042
|
-
shouldRetry
|
1043
|
-
}) : {},
|
1044
|
-
...envMiddleware,
|
1045
|
-
printWarnings,
|
1046
|
-
jsonRequest(),
|
1047
|
-
jsonResponse(),
|
1048
|
-
progress(),
|
1049
|
-
httpError,
|
1050
|
-
observable$1({ implementation: Observable })
|
1051
|
-
]);
|
1052
|
-
function httpRequest(options, requester = request) {
|
1053
|
-
return requester({ maxRedirects: 0, ...options });
|
1054
|
-
}
|
1055
|
-
return httpRequest.defaultRequester = request, httpRequest;
|
1056
|
-
}
|
1057
|
-
function shouldRetry(err, attempt, options) {
|
1058
|
-
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
1059
|
-
return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
|
1060
|
-
}
|
1061
|
-
function getSelection(sel) {
|
1062
|
-
if (typeof sel == "string")
|
1063
|
-
return { id: sel };
|
1064
|
-
if (Array.isArray(sel))
|
1065
|
-
return { query: "*[_id in $ids]", params: { ids: sel } };
|
1066
|
-
if (typeof sel == "object" && sel !== null && "query" in sel && typeof sel.query == "string")
|
1067
|
-
return "params" in sel && typeof sel.params == "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
|
1068
|
-
const selectionOpts = [
|
1069
|
-
"* Document ID (<docId>)",
|
1070
|
-
"* Array of document IDs",
|
1071
|
-
"* Object containing `query`"
|
1072
|
-
].join(`
|
1073
|
-
`);
|
1074
|
-
throw new Error(`Unknown selection - must be one of:
|
1075
|
-
|
1076
|
-
${selectionOpts}`);
|
1077
|
-
}
|
1078
|
-
const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before", "after", "replace"], dataset = (name2) => {
|
1079
|
-
if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name2))
|
1080
|
-
throw new Error(
|
1081
|
-
"Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
|
1082
|
-
);
|
1083
|
-
}, projectId = (id) => {
|
1084
|
-
if (!/^[-a-z0-9]+$/i.test(id))
|
1085
|
-
throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
|
1086
|
-
}, validateAssetType = (type) => {
|
1087
|
-
if (VALID_ASSET_TYPES.indexOf(type) === -1)
|
1088
|
-
throw new Error(`Invalid asset type: ${type}. Must be one of ${VALID_ASSET_TYPES.join(", ")}`);
|
1089
|
-
}, validateObject = (op, val) => {
|
1090
|
-
if (val === null || typeof val != "object" || Array.isArray(val))
|
1091
|
-
throw new Error(`${op}() takes an object of properties`);
|
1092
|
-
}, validateDocumentId = (op, id) => {
|
1093
|
-
if (typeof id != "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes(".."))
|
1094
|
-
throw new Error(`${op}(): "${id}" is not a valid document ID`);
|
1095
|
-
}, requireDocumentId = (op, doc) => {
|
1096
|
-
if (!doc._id)
|
1097
|
-
throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
|
1098
|
-
validateDocumentId(op, doc._id);
|
1099
|
-
}, validateInsert = (at, selector, items) => {
|
1100
|
-
const signature = "insert(at, selector, items)";
|
1101
|
-
if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
|
1102
|
-
const valid = VALID_INSERT_LOCATIONS.map((loc) => `"${loc}"`).join(", ");
|
1103
|
-
throw new Error(`${signature} takes an "at"-argument which is one of: ${valid}`);
|
1104
|
-
}
|
1105
|
-
if (typeof selector != "string")
|
1106
|
-
throw new Error(`${signature} takes a "selector"-argument which must be a string`);
|
1107
|
-
if (!Array.isArray(items))
|
1108
|
-
throw new Error(`${signature} takes an "items"-argument which must be an array`);
|
1109
|
-
}, hasDataset = (config2) => {
|
1110
|
-
if (!config2.dataset)
|
1111
|
-
throw new Error("`dataset` must be provided to perform queries");
|
1112
|
-
return config2.dataset || "";
|
1113
|
-
}, requestTag = (tag) => {
|
1114
|
-
if (typeof tag != "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag))
|
1115
|
-
throw new Error(
|
1116
|
-
"Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long."
|
1117
|
-
);
|
1118
|
-
return tag;
|
1119
|
-
};
|
1120
|
-
var __accessCheck$6 = (obj, member, msg) => {
|
1121
|
-
if (!member.has(obj))
|
1122
|
-
throw TypeError("Cannot " + msg);
|
1123
|
-
}, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
|
1124
|
-
if (member.has(obj))
|
1125
|
-
throw TypeError("Cannot add the same private member more than once");
|
1126
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1127
|
-
}, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
1128
|
-
class BasePatch {
|
1129
|
-
constructor(selection, operations = {}) {
|
1130
|
-
this.selection = selection, this.operations = operations;
|
1131
|
-
}
|
1132
|
-
/**
|
1133
|
-
* Sets the given attributes to the document. Does NOT merge objects.
|
1134
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
1135
|
-
*
|
1136
|
-
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
1137
|
-
*/
|
1138
|
-
set(attrs) {
|
1139
|
-
return this._assign("set", attrs);
|
1140
|
-
}
|
1141
|
-
/**
|
1142
|
-
* Sets the given attributes to the document if they are not currently set. Does NOT merge objects.
|
1143
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
1144
|
-
*
|
1145
|
-
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
1146
|
-
*/
|
1147
|
-
setIfMissing(attrs) {
|
1148
|
-
return this._assign("setIfMissing", attrs);
|
1149
|
-
}
|
1150
|
-
/**
|
1151
|
-
* Performs a "diff-match-patch" operation on the string attributes provided.
|
1152
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
1153
|
-
*
|
1154
|
-
* @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
|
1155
|
-
*/
|
1156
|
-
diffMatchPatch(attrs) {
|
1157
|
-
return validateObject("diffMatchPatch", attrs), this._assign("diffMatchPatch", attrs);
|
1158
|
-
}
|
1159
|
-
/**
|
1160
|
-
* Unsets the attribute paths provided.
|
1161
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
1162
|
-
*
|
1163
|
-
* @param attrs - Attribute paths to unset.
|
1164
|
-
*/
|
1165
|
-
unset(attrs) {
|
1166
|
-
if (!Array.isArray(attrs))
|
1167
|
-
throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
|
1168
|
-
return this.operations = Object.assign({}, this.operations, { unset: attrs }), this;
|
1169
|
-
}
|
1170
|
-
/**
|
1171
|
-
* Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
|
1172
|
-
*
|
1173
|
-
* @param attrs - Object of attribute paths to increment, values representing the number to increment by.
|
1174
|
-
*/
|
1175
|
-
inc(attrs) {
|
1176
|
-
return this._assign("inc", attrs);
|
1177
|
-
}
|
1178
|
-
/**
|
1179
|
-
* Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
|
1180
|
-
*
|
1181
|
-
* @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
|
1182
|
-
*/
|
1183
|
-
dec(attrs) {
|
1184
|
-
return this._assign("dec", attrs);
|
1185
|
-
}
|
1186
|
-
/**
|
1187
|
-
* Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.
|
1188
|
-
*
|
1189
|
-
* @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
|
1190
|
-
* @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
1191
|
-
* @param items - Array of items to insert/replace
|
1192
|
-
*/
|
1193
|
-
insert(at, selector, items) {
|
1194
|
-
return validateInsert(at, selector, items), this._assign("insert", { [at]: selector, items });
|
1195
|
-
}
|
1196
|
-
/**
|
1197
|
-
* Append the given items to the array at the given JSONPath
|
1198
|
-
*
|
1199
|
-
* @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
|
1200
|
-
* @param items - Array of items to append to the array
|
1201
|
-
*/
|
1202
|
-
append(selector, items) {
|
1203
|
-
return this.insert("after", `${selector}[-1]`, items);
|
1204
|
-
}
|
1205
|
-
/**
|
1206
|
-
* Prepend the given items to the array at the given JSONPath
|
1207
|
-
*
|
1208
|
-
* @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
1209
|
-
* @param items - Array of items to prepend to the array
|
1210
|
-
*/
|
1211
|
-
prepend(selector, items) {
|
1212
|
-
return this.insert("before", `${selector}[0]`, items);
|
1213
|
-
}
|
1214
|
-
/**
|
1215
|
-
* Change the contents of an array by removing existing elements and/or adding new elements.
|
1216
|
-
*
|
1217
|
-
* @param selector - Attribute or JSONPath expression for array
|
1218
|
-
* @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x
|
1219
|
-
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
1220
|
-
* @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
|
1221
|
-
*/
|
1222
|
-
splice(selector, start, deleteCount, items) {
|
1223
|
-
const delAll = typeof deleteCount > "u" || deleteCount === -1, startIndex = start < 0 ? start - 1 : start, delCount = delAll ? -1 : Math.max(0, start + deleteCount), delRange = startIndex < 0 && delCount >= 0 ? "" : delCount, rangeSelector = `${selector}[${startIndex}:${delRange}]`;
|
1224
|
-
return this.insert("replace", rangeSelector, items || []);
|
1225
|
-
}
|
1226
|
-
/**
|
1227
|
-
* Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
|
1228
|
-
*
|
1229
|
-
* @param rev - Revision to lock the patch to
|
1230
|
-
*/
|
1231
|
-
ifRevisionId(rev) {
|
1232
|
-
return this.operations.ifRevisionID = rev, this;
|
1233
|
-
}
|
1234
|
-
/**
|
1235
|
-
* Return a plain JSON representation of the patch
|
1236
|
-
*/
|
1237
|
-
serialize() {
|
1238
|
-
return { ...getSelection(this.selection), ...this.operations };
|
1239
|
-
}
|
1240
|
-
/**
|
1241
|
-
* Return a plain JSON representation of the patch
|
1242
|
-
*/
|
1243
|
-
toJSON() {
|
1244
|
-
return this.serialize();
|
1245
|
-
}
|
1246
|
-
/**
|
1247
|
-
* Clears the patch of all operations
|
1248
|
-
*/
|
1249
|
-
reset() {
|
1250
|
-
return this.operations = {}, this;
|
1251
|
-
}
|
1252
|
-
_assign(op, props, merge = !0) {
|
1253
|
-
return validateObject(op, props), this.operations = Object.assign({}, this.operations, {
|
1254
|
-
[op]: Object.assign({}, merge && this.operations[op] || {}, props)
|
1255
|
-
}), this;
|
1256
|
-
}
|
1257
|
-
_set(op, props) {
|
1258
|
-
return this._assign(op, props, !1);
|
1259
|
-
}
|
1260
|
-
}
|
1261
|
-
var _client$5;
|
1262
|
-
const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
|
1263
|
-
constructor(selection, operations, client) {
|
1264
|
-
super(selection, operations), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
|
1265
|
-
}
|
1266
|
-
/**
|
1267
|
-
* Clones the patch
|
1268
|
-
*/
|
1269
|
-
clone() {
|
1270
|
-
return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
|
1271
|
-
}
|
1272
|
-
commit(options) {
|
1273
|
-
if (!__privateGet$6(this, _client$5))
|
1274
|
-
throw new Error(
|
1275
|
-
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
1276
|
-
);
|
1277
|
-
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
1278
|
-
return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
|
1279
|
-
}
|
1280
|
-
};
|
1281
|
-
_client$5 = /* @__PURE__ */ new WeakMap();
|
1282
|
-
let ObservablePatch = _ObservablePatch;
|
1283
|
-
var _client2$5;
|
1284
|
-
const _Patch = class _Patch2 extends BasePatch {
|
1285
|
-
constructor(selection, operations, client) {
|
1286
|
-
super(selection, operations), __privateAdd$6(this, _client2$5, void 0), __privateSet$6(this, _client2$5, client);
|
1287
|
-
}
|
1288
|
-
/**
|
1289
|
-
* Clones the patch
|
1290
|
-
*/
|
1291
|
-
clone() {
|
1292
|
-
return new _Patch2(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
|
1293
|
-
}
|
1294
|
-
commit(options) {
|
1295
|
-
if (!__privateGet$6(this, _client2$5))
|
1296
|
-
throw new Error(
|
1297
|
-
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
1298
|
-
);
|
1299
|
-
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
1300
|
-
return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
|
1301
|
-
}
|
1302
|
-
};
|
1303
|
-
_client2$5 = /* @__PURE__ */ new WeakMap();
|
1304
|
-
let Patch = _Patch;
|
1305
|
-
var __accessCheck$5 = (obj, member, msg) => {
|
1306
|
-
if (!member.has(obj))
|
1307
|
-
throw TypeError("Cannot " + msg);
|
1308
|
-
}, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
|
1309
|
-
if (member.has(obj))
|
1310
|
-
throw TypeError("Cannot add the same private member more than once");
|
1311
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1312
|
-
}, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
1313
|
-
const defaultMutateOptions = { returnDocuments: !1 };
|
1314
|
-
class BaseTransaction {
|
1315
|
-
constructor(operations = [], transactionId) {
|
1316
|
-
this.operations = operations, this.trxId = transactionId;
|
1317
|
-
}
|
1318
|
-
/**
|
1319
|
-
* Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
|
1320
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
1321
|
-
*
|
1322
|
-
* @param doc - Document to create. Requires a `_type` property.
|
1323
|
-
*/
|
1324
|
-
create(doc) {
|
1325
|
-
return validateObject("create", doc), this._add({ create: doc });
|
1326
|
-
}
|
1327
|
-
/**
|
1328
|
-
* Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
|
1329
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
1330
|
-
*
|
1331
|
-
* @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
1332
|
-
*/
|
1333
|
-
createIfNotExists(doc) {
|
1334
|
-
const op = "createIfNotExists";
|
1335
|
-
return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
|
1336
|
-
}
|
1337
|
-
/**
|
1338
|
-
* Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
|
1339
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
1340
|
-
*
|
1341
|
-
* @param doc - Document to create or replace. Requires `_id` and `_type` properties.
|
1342
|
-
*/
|
1343
|
-
createOrReplace(doc) {
|
1344
|
-
const op = "createOrReplace";
|
1345
|
-
return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
|
1346
|
-
}
|
1347
|
-
/**
|
1348
|
-
* Deletes the document with the given document ID
|
1349
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
1350
|
-
*
|
1351
|
-
* @param documentId - Document ID to delete
|
1352
|
-
*/
|
1353
|
-
delete(documentId) {
|
1354
|
-
return validateDocumentId("delete", documentId), this._add({ delete: { id: documentId } });
|
1355
|
-
}
|
1356
|
-
transactionId(id) {
|
1357
|
-
return id ? (this.trxId = id, this) : this.trxId;
|
1358
|
-
}
|
1359
|
-
/**
|
1360
|
-
* Return a plain JSON representation of the transaction
|
1361
|
-
*/
|
1362
|
-
serialize() {
|
1363
|
-
return [...this.operations];
|
1364
|
-
}
|
1365
|
-
/**
|
1366
|
-
* Return a plain JSON representation of the transaction
|
1367
|
-
*/
|
1368
|
-
toJSON() {
|
1369
|
-
return this.serialize();
|
1370
|
-
}
|
1371
|
-
/**
|
1372
|
-
* Clears the transaction of all operations
|
1373
|
-
*/
|
1374
|
-
reset() {
|
1375
|
-
return this.operations = [], this;
|
1376
|
-
}
|
1377
|
-
_add(mut) {
|
1378
|
-
return this.operations.push(mut), this;
|
1379
|
-
}
|
1380
|
-
}
|
1381
|
-
var _client$4;
|
1382
|
-
const _Transaction = class _Transaction2 extends BaseTransaction {
|
1383
|
-
constructor(operations, client, transactionId) {
|
1384
|
-
super(operations, transactionId), __privateAdd$5(this, _client$4, void 0), __privateSet$5(this, _client$4, client);
|
1385
|
-
}
|
1386
|
-
/**
|
1387
|
-
* Clones the transaction
|
1388
|
-
*/
|
1389
|
-
clone() {
|
1390
|
-
return new _Transaction2([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
1391
|
-
}
|
1392
|
-
commit(options) {
|
1393
|
-
if (!__privateGet$5(this, _client$4))
|
1394
|
-
throw new Error(
|
1395
|
-
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
1396
|
-
);
|
1397
|
-
return __privateGet$5(this, _client$4).mutate(
|
1398
|
-
this.serialize(),
|
1399
|
-
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
1400
|
-
);
|
1401
|
-
}
|
1402
|
-
patch(patchOrDocumentId, patchOps) {
|
1403
|
-
const isBuilder = typeof patchOps == "function";
|
1404
|
-
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
1405
|
-
return this._add({ patch: patchOrDocumentId.serialize() });
|
1406
|
-
if (isBuilder) {
|
1407
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
1408
|
-
if (!(patch instanceof Patch))
|
1409
|
-
throw new Error("function passed to `patch()` must return the patch");
|
1410
|
-
return this._add({ patch: patch.serialize() });
|
1411
|
-
}
|
1412
|
-
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
1413
|
-
}
|
1414
|
-
};
|
1415
|
-
_client$4 = /* @__PURE__ */ new WeakMap();
|
1416
|
-
let Transaction = _Transaction;
|
1417
|
-
var _client2$4;
|
1418
|
-
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
1419
|
-
constructor(operations, client, transactionId) {
|
1420
|
-
super(operations, transactionId), __privateAdd$5(this, _client2$4, void 0), __privateSet$5(this, _client2$4, client);
|
1421
|
-
}
|
1422
|
-
/**
|
1423
|
-
* Clones the transaction
|
1424
|
-
*/
|
1425
|
-
clone() {
|
1426
|
-
return new _ObservableTransaction2([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
1427
|
-
}
|
1428
|
-
commit(options) {
|
1429
|
-
if (!__privateGet$5(this, _client2$4))
|
1430
|
-
throw new Error(
|
1431
|
-
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
1432
|
-
);
|
1433
|
-
return __privateGet$5(this, _client2$4).mutate(
|
1434
|
-
this.serialize(),
|
1435
|
-
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
1436
|
-
);
|
1437
|
-
}
|
1438
|
-
patch(patchOrDocumentId, patchOps) {
|
1439
|
-
const isBuilder = typeof patchOps == "function";
|
1440
|
-
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
1441
|
-
return this._add({ patch: patchOrDocumentId.serialize() });
|
1442
|
-
if (isBuilder) {
|
1443
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
1444
|
-
if (!(patch instanceof ObservablePatch))
|
1445
|
-
throw new Error("function passed to `patch()` must return the patch");
|
1446
|
-
return this._add({ patch: patch.serialize() });
|
1447
|
-
}
|
1448
|
-
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
1449
|
-
}
|
1450
|
-
};
|
1451
|
-
_client2$4 = /* @__PURE__ */ new WeakMap();
|
1452
|
-
let ObservableTransaction = _ObservableTransaction;
|
1453
|
-
const BASE_URL = "https://www.sanity.io/help/";
|
1454
|
-
function generateHelpUrl(slug) {
|
1455
|
-
return BASE_URL + slug;
|
1456
|
-
}
|
1457
|
-
function once(fn) {
|
1458
|
-
let didCall = !1, returnValue;
|
1459
|
-
return (...args) => (didCall || (returnValue = fn(...args), didCall = !0), returnValue);
|
1460
|
-
}
|
1461
|
-
const createWarningPrinter = (message) => (
|
1462
|
-
// eslint-disable-next-line no-console
|
1463
|
-
once((...args) => console.warn(message.join(" "), ...args))
|
1464
|
-
), printCdnWarning = createWarningPrinter([
|
1465
|
-
"Since you haven't set a value for `useCdn`, we will deliver content using our",
|
1466
|
-
"global, edge-cached API-CDN. If you wish to have content delivered faster, set",
|
1467
|
-
"`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
|
1468
|
-
]), printCdnPreviewDraftsWarning = createWarningPrinter([
|
1469
|
-
"The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
|
1470
|
-
"The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
|
1471
|
-
]), printBrowserTokenWarning = createWarningPrinter([
|
1472
|
-
"You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
|
1473
|
-
`See ${generateHelpUrl(
|
1474
|
-
"js-client-browser-token"
|
1475
|
-
)} for more information and how to hide this warning.`
|
1476
|
-
]), printNoApiVersionSpecifiedWarning = createWarningPrinter([
|
1477
|
-
"Using the Sanity client without specifying an API version is deprecated.",
|
1478
|
-
`See ${generateHelpUrl("js-client-api-version")}`
|
1479
|
-
]), defaultCdnHost = "apicdn.sanity.io", defaultConfig = {
|
1480
|
-
apiHost: "https://api.sanity.io",
|
1481
|
-
apiVersion: "1",
|
1482
|
-
useProjectHostname: !0,
|
1483
|
-
stega: { enabled: !1 }
|
1484
|
-
}, LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"], isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
|
1485
|
-
function validateApiVersion(apiVersion) {
|
1486
|
-
if (apiVersion === "1" || apiVersion === "X")
|
1487
|
-
return;
|
1488
|
-
const apiDate = new Date(apiVersion);
|
1489
|
-
if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
|
1490
|
-
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
1491
|
-
}
|
1492
|
-
const validateApiPerspective = function(perspective) {
|
1493
|
-
switch (perspective) {
|
1494
|
-
case "previewDrafts":
|
1495
|
-
case "published":
|
1496
|
-
case "raw":
|
1497
|
-
return;
|
1498
|
-
default:
|
1499
|
-
throw new TypeError(
|
1500
|
-
"Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
|
1501
|
-
);
|
1502
|
-
}
|
1503
|
-
}, initConfig = (config2, prevConfig) => {
|
1504
|
-
const specifiedConfig = {
|
1505
|
-
...prevConfig,
|
1506
|
-
...config2,
|
1507
|
-
stega: {
|
1508
|
-
...typeof prevConfig.stega == "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
|
1509
|
-
...typeof config2.stega == "boolean" ? { enabled: config2.stega } : config2.stega || {}
|
1510
|
-
}
|
1511
|
-
};
|
1512
|
-
specifiedConfig.apiVersion || printNoApiVersionSpecifiedWarning();
|
1513
|
-
const newConfig = {
|
1514
|
-
...defaultConfig,
|
1515
|
-
...specifiedConfig
|
1516
|
-
}, projectBased = newConfig.useProjectHostname;
|
1517
|
-
if (typeof Promise > "u") {
|
1518
|
-
const helpUrl = generateHelpUrl("js-client-promise-polyfill");
|
1519
|
-
throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`);
|
1520
|
-
}
|
1521
|
-
if (projectBased && !newConfig.projectId)
|
1522
|
-
throw new Error("Configuration must contain `projectId`");
|
1523
|
-
if (typeof newConfig.perspective == "string" && validateApiPerspective(newConfig.perspective), "encodeSourceMap" in newConfig)
|
1524
|
-
throw new Error(
|
1525
|
-
"It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?"
|
1526
|
-
);
|
1527
|
-
if ("encodeSourceMapAtPath" in newConfig)
|
1528
|
-
throw new Error(
|
1529
|
-
"It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?"
|
1530
|
-
);
|
1531
|
-
if (typeof newConfig.stega.enabled != "boolean")
|
1532
|
-
throw new Error(`stega.enabled must be a boolean, received ${newConfig.stega.enabled}`);
|
1533
|
-
if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0)
|
1534
|
-
throw new Error("stega.studioUrl must be defined when stega.enabled is true");
|
1535
|
-
if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl != "string" && typeof newConfig.stega.studioUrl != "function")
|
1536
|
-
throw new Error(
|
1537
|
-
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
1538
|
-
);
|
1539
|
-
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
|
1540
|
-
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== !0 ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn = newConfig.useCdn !== !1 && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
1541
|
-
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
1542
|
-
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
|
1543
|
-
}, projectHeader = "X-Sanity-Project-ID";
|
1544
|
-
function requestOptions(config2, overrides = {}) {
|
1545
|
-
const headers2 = {}, token = overrides.token || config2.token;
|
1546
|
-
token && (headers2.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config2.useProjectHostname && config2.projectId && (headers2[projectHeader] = config2.projectId);
|
1547
|
-
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config2.token || config2.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config2.timeout : overrides.timeout;
|
1548
|
-
return Object.assign({}, overrides, {
|
1549
|
-
headers: Object.assign({}, headers2, overrides.headers || {}),
|
1550
|
-
timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
|
1551
|
-
proxy: overrides.proxy || config2.proxy,
|
1552
|
-
json: !0,
|
1553
|
-
withCredentials,
|
1554
|
-
fetch: typeof overrides.fetch == "object" && typeof config2.fetch == "object" ? { ...config2.fetch, ...overrides.fetch } : overrides.fetch || config2.fetch
|
1555
|
-
});
|
1556
|
-
}
|
1557
|
-
var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 };
|
1558
|
-
new Array(4).fill(String.fromCodePoint(c[0])).join("");
|
1559
|
-
Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
|
1560
|
-
Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
|
1561
|
-
var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
|
1562
|
-
function X(t) {
|
1563
|
-
var e;
|
1564
|
-
return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? void 0 : e[0]) || "" };
|
1565
|
-
}
|
1566
|
-
function vercelStegaCleanAll(result) {
|
1567
|
-
try {
|
1568
|
-
return JSON.parse(
|
1569
|
-
JSON.stringify(result, (key, value) => typeof value != "string" ? value : X(value).cleaned)
|
1570
|
-
);
|
1571
|
-
} catch {
|
1572
|
-
return result;
|
1573
|
-
}
|
1574
|
-
}
|
1575
|
-
const encodeQueryString = ({
|
1576
|
-
query,
|
1577
|
-
params = {},
|
1578
|
-
options = {}
|
1579
|
-
}) => {
|
1580
|
-
const searchParams = new URLSearchParams(), { tag, returnQuery, ...opts } = options;
|
1581
|
-
tag && searchParams.append("tag", tag), searchParams.append("query", query);
|
1582
|
-
for (const [key, value] of Object.entries(params))
|
1583
|
-
searchParams.append(`$${key}`, JSON.stringify(value));
|
1584
|
-
for (const [key, value] of Object.entries(opts))
|
1585
|
-
value && searchParams.append(key, `${value}`);
|
1586
|
-
return returnQuery === !1 && searchParams.append("returnQuery", "false"), `?${searchParams}`;
|
1587
|
-
}, excludeFalsey = (param, defValue) => param === !1 ? void 0 : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
|
1588
|
-
dryRun: options.dryRun,
|
1589
|
-
returnIds: !0,
|
1590
|
-
returnDocuments: excludeFalsey(options.returnDocuments, !0),
|
1591
|
-
visibility: options.visibility || "sync",
|
1592
|
-
autoGenerateArrayKeys: options.autoGenerateArrayKeys,
|
1593
|
-
skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
|
1594
|
-
}), isResponse = (event) => event.type === "response", getBody = (event) => event.body, indexBy = (docs, attr) => docs.reduce((indexed, doc) => (indexed[attr(doc)] = doc, indexed), /* @__PURE__ */ Object.create(null)), getQuerySizeLimit = 11264;
|
1595
|
-
function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
1596
|
-
const stega = "stega" in options ? {
|
1597
|
-
..._stega || {},
|
1598
|
-
...typeof options.stega == "boolean" ? { enabled: options.stega } : options.stega || {}
|
1599
|
-
} : _stega, params = stega.enabled ? vercelStegaCleanAll(_params) : _params, mapResponse = options.filterResponse === !1 ? (res) => res : (res) => res.result, { cache, next, ...opts } = {
|
1600
|
-
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
1601
|
-
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
1602
|
-
useAbortSignal: typeof options.signal < "u",
|
1603
|
-
// Set `resultSourceMap' when stega is enabled, as it's required for encoding.
|
1604
|
-
resultSourceMap: stega.enabled ? "withKeyArraySelector" : options.resultSourceMap,
|
1605
|
-
...options,
|
1606
|
-
// Default to not returning the query, unless `filterResponse` is `false`,
|
1607
|
-
// or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
|
1608
|
-
returnQuery: options.filterResponse === !1 && options.returnQuery !== !1
|
1609
|
-
}, reqOpts = typeof cache < "u" || typeof next < "u" ? { ...opts, fetch: { cache, next } } : opts, $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
|
1610
|
-
return stega.enabled ? $request.pipe(
|
1611
|
-
combineLatestWith(
|
1612
|
-
from(
|
1613
|
-
import("./stegaEncodeSourceMap.js").then(function(n) {
|
1614
|
-
return n.a;
|
1615
|
-
}).then(
|
1616
|
-
({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
|
1617
|
-
)
|
1618
|
-
)
|
1619
|
-
),
|
1620
|
-
map(
|
1621
|
-
([res, stegaEncodeSourceMap]) => {
|
1622
|
-
const result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega);
|
1623
|
-
return mapResponse({ ...res, result });
|
1624
|
-
}
|
1625
|
-
)
|
1626
|
-
) : $request.pipe(map(mapResponse));
|
1627
|
-
}
|
1628
|
-
function _getDocument(client, httpRequest, id, opts = {}) {
|
1629
|
-
const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag };
|
1630
|
-
return _requestObservable(client, httpRequest, options).pipe(
|
1631
|
-
filter(isResponse),
|
1632
|
-
map((event) => event.body.documents && event.body.documents[0])
|
1633
|
-
);
|
1634
|
-
}
|
1635
|
-
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
1636
|
-
const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag };
|
1637
|
-
return _requestObservable(client, httpRequest, options).pipe(
|
1638
|
-
filter(isResponse),
|
1639
|
-
map((event) => {
|
1640
|
-
const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
|
1641
|
-
return ids.map((id) => indexed[id] || null);
|
1642
|
-
})
|
1643
|
-
);
|
1644
|
-
}
|
1645
|
-
function _createIfNotExists(client, httpRequest, doc, options) {
|
1646
|
-
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
1647
|
-
}
|
1648
|
-
function _createOrReplace(client, httpRequest, doc, options) {
|
1649
|
-
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
1650
|
-
}
|
1651
|
-
function _delete(client, httpRequest, selection, options) {
|
1652
|
-
return _dataRequest(
|
1653
|
-
client,
|
1654
|
-
httpRequest,
|
1655
|
-
"mutate",
|
1656
|
-
{ mutations: [{ delete: getSelection(selection) }] },
|
1657
|
-
options
|
1658
|
-
);
|
1659
|
-
}
|
1660
|
-
function _mutate(client, httpRequest, mutations, options) {
|
1661
|
-
let mut;
|
1662
|
-
mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
|
1663
|
-
const muts = Array.isArray(mut) ? mut : [mut], transactionId = options && options.transactionId || void 0;
|
1664
|
-
return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
|
1665
|
-
}
|
1666
|
-
function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
1667
|
-
const isMutation = endpoint === "mutate", isQuery = endpoint === "query", strQuery = isMutation ? "" : encodeQueryString(body), useGet = !isMutation && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers: headers2, returnQuery } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
|
1668
|
-
method: useGet ? "GET" : "POST",
|
1669
|
-
uri,
|
1670
|
-
json: !0,
|
1671
|
-
body: useGet ? void 0 : body,
|
1672
|
-
query: isMutation && getMutationQuery(options),
|
1673
|
-
timeout,
|
1674
|
-
headers: headers2,
|
1675
|
-
token,
|
1676
|
-
tag,
|
1677
|
-
returnQuery,
|
1678
|
-
perspective: options.perspective,
|
1679
|
-
resultSourceMap: options.resultSourceMap,
|
1680
|
-
canUseCdn: isQuery,
|
1681
|
-
signal: options.signal,
|
1682
|
-
fetch: options.fetch,
|
1683
|
-
useAbortSignal: options.useAbortSignal,
|
1684
|
-
useCdn: options.useCdn
|
1685
|
-
};
|
1686
|
-
return _requestObservable(client, httpRequest, reqOptions).pipe(
|
1687
|
-
filter(isResponse),
|
1688
|
-
map(getBody),
|
1689
|
-
map((res) => {
|
1690
|
-
if (!isMutation)
|
1691
|
-
return res;
|
1692
|
-
const results = res.results || [];
|
1693
|
-
if (options.returnDocuments)
|
1694
|
-
return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
|
1695
|
-
const key = returnFirst ? "documentId" : "documentIds", ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
|
1696
|
-
return {
|
1697
|
-
transactionId: res.transactionId,
|
1698
|
-
results,
|
1699
|
-
[key]: ids
|
1700
|
-
};
|
1701
|
-
})
|
1702
|
-
);
|
1703
|
-
}
|
1704
|
-
function _create(client, httpRequest, doc, op, options = {}) {
|
1705
|
-
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
|
1706
|
-
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
1707
|
-
}
|
1708
|
-
function _requestObservable(client, httpRequest, options) {
|
1709
|
-
var _a, _b;
|
1710
|
-
const uri = options.url || options.uri, config2 = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
|
1711
|
-
let useCdn = ((_a = options.useCdn) != null ? _a : config2.useCdn) && canUseCdn;
|
1712
|
-
const tag = options.tag && config2.requestTagPrefix ? [config2.requestTagPrefix, options.tag].join(".") : options.tag || config2.requestTagPrefix;
|
1713
|
-
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
1714
|
-
const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config2.resultSourceMap;
|
1715
|
-
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
1716
|
-
const perspective = options.perspective || config2.perspective;
|
1717
|
-
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
|
1718
|
-
}
|
1719
|
-
const reqOptions = requestOptions(
|
1720
|
-
config2,
|
1721
|
-
Object.assign({}, options, {
|
1722
|
-
url: _getUrl(client, uri, useCdn)
|
1723
|
-
})
|
1724
|
-
), request = new Observable(
|
1725
|
-
(subscriber) => httpRequest(reqOptions, config2.requester).subscribe(subscriber)
|
1726
|
-
);
|
1727
|
-
return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
|
1728
|
-
}
|
1729
|
-
function _request(client, httpRequest, options) {
|
1730
|
-
return _requestObservable(client, httpRequest, options).pipe(
|
1731
|
-
filter((event) => event.type === "response"),
|
1732
|
-
map((event) => event.body)
|
1733
|
-
);
|
1734
|
-
}
|
1735
|
-
function _getDataUrl(client, operation, path2) {
|
1736
|
-
const config2 = client.config(), catalog = hasDataset(config2), baseUri = `/${operation}/${catalog}`;
|
1737
|
-
return `/data${path2 ? `${baseUri}/${path2}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
1738
|
-
}
|
1739
|
-
function _getUrl(client, uri, canUseCdn = !1) {
|
1740
|
-
const { url, cdnUrl } = client.config();
|
1741
|
-
return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
|
1742
|
-
}
|
1743
|
-
function _withAbortSignal(signal) {
|
1744
|
-
return (input) => new Observable((observer) => {
|
1745
|
-
const abort = () => observer.error(_createAbortError(signal));
|
1746
|
-
if (signal && signal.aborted) {
|
1747
|
-
abort();
|
1748
|
-
return;
|
1749
|
-
}
|
1750
|
-
const subscription = input.subscribe(observer);
|
1751
|
-
return signal.addEventListener("abort", abort), () => {
|
1752
|
-
signal.removeEventListener("abort", abort), subscription.unsubscribe();
|
1753
|
-
};
|
1754
|
-
});
|
1755
|
-
}
|
1756
|
-
const isDomExceptionSupported = !!globalThis.DOMException;
|
1757
|
-
function _createAbortError(signal) {
|
1758
|
-
var _a, _b;
|
1759
|
-
if (isDomExceptionSupported)
|
1760
|
-
return new DOMException((_a = signal?.reason) != null ? _a : "The operation was aborted.", "AbortError");
|
1761
|
-
const error = new Error((_b = signal?.reason) != null ? _b : "The operation was aborted.");
|
1762
|
-
return error.name = "AbortError", error;
|
1763
|
-
}
|
1764
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
1765
|
-
if (!member.has(obj))
|
1766
|
-
throw TypeError("Cannot " + msg);
|
1767
|
-
}, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
|
1768
|
-
if (member.has(obj))
|
1769
|
-
throw TypeError("Cannot add the same private member more than once");
|
1770
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1771
|
-
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$3, _httpRequest$4;
|
1772
|
-
class ObservableAssetsClient {
|
1773
|
-
constructor(client, httpRequest) {
|
1774
|
-
__privateAdd$4(this, _client$3, void 0), __privateAdd$4(this, _httpRequest$4, void 0), __privateSet$4(this, _client$3, client), __privateSet$4(this, _httpRequest$4, httpRequest);
|
1775
|
-
}
|
1776
|
-
upload(assetType, body, options) {
|
1777
|
-
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
1778
|
-
}
|
1779
|
-
}
|
1780
|
-
_client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
1781
|
-
var _client2$3, _httpRequest2$4;
|
1782
|
-
class AssetsClient {
|
1783
|
-
constructor(client, httpRequest) {
|
1784
|
-
__privateAdd$4(this, _client2$3, void 0), __privateAdd$4(this, _httpRequest2$4, void 0), __privateSet$4(this, _client2$3, client), __privateSet$4(this, _httpRequest2$4, httpRequest);
|
1785
|
-
}
|
1786
|
-
upload(assetType, body, options) {
|
1787
|
-
const observable2 = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
1788
|
-
return lastValueFrom(
|
1789
|
-
observable2.pipe(
|
1790
|
-
filter((event) => event.type === "response"),
|
1791
|
-
map(
|
1792
|
-
(event) => event.body.document
|
1793
|
-
)
|
1794
|
-
)
|
1795
|
-
);
|
1796
|
-
}
|
1797
|
-
}
|
1798
|
-
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
1799
|
-
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
1800
|
-
validateAssetType(assetType);
|
1801
|
-
let meta = opts.extract || void 0;
|
1802
|
-
meta && !meta.length && (meta = ["none"]);
|
1803
|
-
const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description: description2, creditLine, filename, source } = options, query = {
|
1804
|
-
label,
|
1805
|
-
title,
|
1806
|
-
description: description2,
|
1807
|
-
filename,
|
1808
|
-
meta,
|
1809
|
-
creditLine
|
1810
|
-
};
|
1811
|
-
return source && (query.sourceId = source.id, query.sourceName = source.name, query.sourceUrl = source.url), _requestObservable(client, httpRequest, {
|
1812
|
-
tag,
|
1813
|
-
method: "POST",
|
1814
|
-
timeout: options.timeout || 0,
|
1815
|
-
uri: `/assets/${assetEndpoint}/${dataset2}`,
|
1816
|
-
headers: options.contentType ? { "Content-Type": options.contentType } : {},
|
1817
|
-
query,
|
1818
|
-
body
|
1819
|
-
});
|
1820
|
-
}
|
1821
|
-
function optionsFromFile(opts, file) {
|
1822
|
-
return typeof File > "u" || !(file instanceof File) ? opts : Object.assign(
|
1823
|
-
{
|
1824
|
-
filename: opts.preserveFilename === !1 ? void 0 : file.name,
|
1825
|
-
contentType: file.type
|
1826
|
-
},
|
1827
|
-
opts
|
1828
|
-
);
|
1829
|
-
}
|
1830
|
-
var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = typeof obj[prop] > "u" ? defaults2[prop] : obj[prop], target), {});
|
1831
|
-
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), MAX_URL_LENGTH = 14800, possibleOptions = [
|
1832
|
-
"includePreviousRevision",
|
1833
|
-
"includeResult",
|
1834
|
-
"visibility",
|
1835
|
-
"effectFormat",
|
1836
|
-
"tag"
|
1837
|
-
], defaultOptions = {
|
1838
|
-
includeResult: !0
|
1839
|
-
};
|
1840
|
-
function _listen(query, params, opts = {}) {
|
1841
|
-
const { url, token, withCredentials, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = { ...defaults(opts, defaultOptions), tag }, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } }), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
1842
|
-
if (uri.length > MAX_URL_LENGTH)
|
1843
|
-
return new Observable((observer) => observer.error(new Error("Query too large for listener")));
|
1844
|
-
const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1, esOptions = {};
|
1845
|
-
return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
|
1846
|
-
Authorization: `Bearer ${token}`
|
1847
|
-
}), new Observable((observer) => {
|
1848
|
-
let es;
|
1849
|
-
getEventSource().then((eventSource) => {
|
1850
|
-
es = eventSource;
|
1851
|
-
}).catch((reason) => {
|
1852
|
-
observer.error(reason), stop();
|
1853
|
-
});
|
1854
|
-
let reconnectTimer, stopped = !1;
|
1855
|
-
function onError() {
|
1856
|
-
stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
|
1857
|
-
}
|
1858
|
-
function onChannelError(err) {
|
1859
|
-
observer.error(cooerceError(err));
|
1860
|
-
}
|
1861
|
-
function onMessage(evt) {
|
1862
|
-
const event = parseEvent(evt);
|
1863
|
-
return event instanceof Error ? observer.error(event) : observer.next(event);
|
1864
|
-
}
|
1865
|
-
function onDisconnect() {
|
1866
|
-
stopped = !0, unsubscribe(), observer.complete();
|
1867
|
-
}
|
1868
|
-
function unsubscribe() {
|
1869
|
-
es && (es.removeEventListener("error", onError), es.removeEventListener("channelError", onChannelError), es.removeEventListener("disconnect", onDisconnect), listenFor.forEach((type) => es.removeEventListener(type, onMessage)), es.close());
|
1870
|
-
}
|
1871
|
-
function emitReconnect() {
|
1872
|
-
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
1873
|
-
}
|
1874
|
-
async function getEventSource() {
|
1875
|
-
const { default: EventSource } = await import("./node.js").then(function(n) {
|
1876
|
-
return n.n;
|
1877
|
-
}), evs = new EventSource(uri, esOptions);
|
1878
|
-
return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
|
1879
|
-
}
|
1880
|
-
function open() {
|
1881
|
-
getEventSource().then((eventSource) => {
|
1882
|
-
es = eventSource;
|
1883
|
-
}).catch((reason) => {
|
1884
|
-
observer.error(reason), stop();
|
1885
|
-
});
|
1886
|
-
}
|
1887
|
-
function stop() {
|
1888
|
-
stopped = !0, unsubscribe();
|
1889
|
-
}
|
1890
|
-
return stop;
|
1891
|
-
});
|
1892
|
-
}
|
1893
|
-
function parseEvent(event) {
|
1894
|
-
try {
|
1895
|
-
const data = event.data && JSON.parse(event.data) || {};
|
1896
|
-
return Object.assign({ type: event.type }, data);
|
1897
|
-
} catch (err) {
|
1898
|
-
return err;
|
1899
|
-
}
|
1900
|
-
}
|
1901
|
-
function cooerceError(err) {
|
1902
|
-
if (err instanceof Error)
|
1903
|
-
return err;
|
1904
|
-
const evt = parseEvent(err);
|
1905
|
-
return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
|
1906
|
-
}
|
1907
|
-
function extractErrorMessage(err) {
|
1908
|
-
return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
|
1909
|
-
}
|
1910
|
-
var __accessCheck$3 = (obj, member, msg) => {
|
1911
|
-
if (!member.has(obj))
|
1912
|
-
throw TypeError("Cannot " + msg);
|
1913
|
-
}, __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$3 = (obj, member, value) => {
|
1914
|
-
if (member.has(obj))
|
1915
|
-
throw TypeError("Cannot add the same private member more than once");
|
1916
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1917
|
-
}, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$2, _httpRequest$3;
|
1918
|
-
class ObservableDatasetsClient {
|
1919
|
-
constructor(client, httpRequest) {
|
1920
|
-
__privateAdd$3(this, _client$2, void 0), __privateAdd$3(this, _httpRequest$3, void 0), __privateSet$3(this, _client$2, client), __privateSet$3(this, _httpRequest$3, httpRequest);
|
1921
|
-
}
|
1922
|
-
/**
|
1923
|
-
* Create a new dataset with the given name
|
1924
|
-
*
|
1925
|
-
* @param name - Name of the dataset to create
|
1926
|
-
* @param options - Options for the dataset
|
1927
|
-
*/
|
1928
|
-
create(name2, options) {
|
1929
|
-
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name2, options);
|
1930
|
-
}
|
1931
|
-
/**
|
1932
|
-
* Edit a dataset with the given name
|
1933
|
-
*
|
1934
|
-
* @param name - Name of the dataset to edit
|
1935
|
-
* @param options - New options for the dataset
|
1936
|
-
*/
|
1937
|
-
edit(name2, options) {
|
1938
|
-
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name2, options);
|
1939
|
-
}
|
1940
|
-
/**
|
1941
|
-
* Delete a dataset with the given name
|
1942
|
-
*
|
1943
|
-
* @param name - Name of the dataset to delete
|
1944
|
-
*/
|
1945
|
-
delete(name2) {
|
1946
|
-
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name2);
|
1947
|
-
}
|
1948
|
-
/**
|
1949
|
-
* Fetch a list of datasets for the configured project
|
1950
|
-
*/
|
1951
|
-
list() {
|
1952
|
-
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
1953
|
-
uri: "/datasets",
|
1954
|
-
tag: null
|
1955
|
-
});
|
1956
|
-
}
|
1957
|
-
}
|
1958
|
-
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
1959
|
-
var _client2$2, _httpRequest2$3;
|
1960
|
-
class DatasetsClient {
|
1961
|
-
constructor(client, httpRequest) {
|
1962
|
-
__privateAdd$3(this, _client2$2, void 0), __privateAdd$3(this, _httpRequest2$3, void 0), __privateSet$3(this, _client2$2, client), __privateSet$3(this, _httpRequest2$3, httpRequest);
|
1963
|
-
}
|
1964
|
-
/**
|
1965
|
-
* Create a new dataset with the given name
|
1966
|
-
*
|
1967
|
-
* @param name - Name of the dataset to create
|
1968
|
-
* @param options - Options for the dataset
|
1969
|
-
*/
|
1970
|
-
create(name2, options) {
|
1971
|
-
return lastValueFrom(
|
1972
|
-
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name2, options)
|
1973
|
-
);
|
1974
|
-
}
|
1975
|
-
/**
|
1976
|
-
* Edit a dataset with the given name
|
1977
|
-
*
|
1978
|
-
* @param name - Name of the dataset to edit
|
1979
|
-
* @param options - New options for the dataset
|
1980
|
-
*/
|
1981
|
-
edit(name2, options) {
|
1982
|
-
return lastValueFrom(
|
1983
|
-
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name2, options)
|
1984
|
-
);
|
1985
|
-
}
|
1986
|
-
/**
|
1987
|
-
* Delete a dataset with the given name
|
1988
|
-
*
|
1989
|
-
* @param name - Name of the dataset to delete
|
1990
|
-
*/
|
1991
|
-
delete(name2) {
|
1992
|
-
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name2));
|
1993
|
-
}
|
1994
|
-
/**
|
1995
|
-
* Fetch a list of datasets for the configured project
|
1996
|
-
*/
|
1997
|
-
list() {
|
1998
|
-
return lastValueFrom(
|
1999
|
-
_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
|
2000
|
-
);
|
2001
|
-
}
|
2002
|
-
}
|
2003
|
-
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
2004
|
-
function _modify(client, httpRequest, method, name2, options) {
|
2005
|
-
return dataset(name2), _request(client, httpRequest, {
|
2006
|
-
method,
|
2007
|
-
uri: `/datasets/${name2}`,
|
2008
|
-
body: options,
|
2009
|
-
tag: null
|
2010
|
-
});
|
2011
|
-
}
|
2012
|
-
var __accessCheck$2 = (obj, member, msg) => {
|
2013
|
-
if (!member.has(obj))
|
2014
|
-
throw TypeError("Cannot " + msg);
|
2015
|
-
}, __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$2 = (obj, member, value) => {
|
2016
|
-
if (member.has(obj))
|
2017
|
-
throw TypeError("Cannot add the same private member more than once");
|
2018
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2019
|
-
}, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$1, _httpRequest$2;
|
2020
|
-
class ObservableProjectsClient {
|
2021
|
-
constructor(client, httpRequest) {
|
2022
|
-
__privateAdd$2(this, _client$1, void 0), __privateAdd$2(this, _httpRequest$2, void 0), __privateSet$2(this, _client$1, client), __privateSet$2(this, _httpRequest$2, httpRequest);
|
2023
|
-
}
|
2024
|
-
list(options) {
|
2025
|
-
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
2026
|
-
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
|
2027
|
-
}
|
2028
|
-
/**
|
2029
|
-
* Fetch a project by project ID
|
2030
|
-
*
|
2031
|
-
* @param projectId - ID of the project to fetch
|
2032
|
-
*/
|
2033
|
-
getById(projectId2) {
|
2034
|
-
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
|
2035
|
-
}
|
2036
|
-
}
|
2037
|
-
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
2038
|
-
var _client2$1, _httpRequest2$2;
|
2039
|
-
class ProjectsClient {
|
2040
|
-
constructor(client, httpRequest) {
|
2041
|
-
__privateAdd$2(this, _client2$1, void 0), __privateAdd$2(this, _httpRequest2$2, void 0), __privateSet$2(this, _client2$1, client), __privateSet$2(this, _httpRequest2$2, httpRequest);
|
2042
|
-
}
|
2043
|
-
list(options) {
|
2044
|
-
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
2045
|
-
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
|
2046
|
-
}
|
2047
|
-
/**
|
2048
|
-
* Fetch a project by project ID
|
2049
|
-
*
|
2050
|
-
* @param projectId - ID of the project to fetch
|
2051
|
-
*/
|
2052
|
-
getById(projectId2) {
|
2053
|
-
return lastValueFrom(
|
2054
|
-
_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
|
2055
|
-
);
|
2056
|
-
}
|
2057
|
-
}
|
2058
|
-
_client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
|
2059
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
2060
|
-
if (!member.has(obj))
|
2061
|
-
throw TypeError("Cannot " + msg);
|
2062
|
-
}, __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$1 = (obj, member, value) => {
|
2063
|
-
if (member.has(obj))
|
2064
|
-
throw TypeError("Cannot add the same private member more than once");
|
2065
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2066
|
-
}, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client, _httpRequest$1;
|
2067
|
-
class ObservableUsersClient {
|
2068
|
-
constructor(client, httpRequest) {
|
2069
|
-
__privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
|
2070
|
-
}
|
2071
|
-
/**
|
2072
|
-
* Fetch a user by user ID
|
2073
|
-
*
|
2074
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
2075
|
-
*/
|
2076
|
-
getById(id) {
|
2077
|
-
return _request(
|
2078
|
-
__privateGet$1(this, _client),
|
2079
|
-
__privateGet$1(this, _httpRequest$1),
|
2080
|
-
{ uri: `/users/${id}` }
|
2081
|
-
);
|
2082
|
-
}
|
2083
|
-
}
|
2084
|
-
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
2085
|
-
var _client2, _httpRequest2$1;
|
2086
|
-
class UsersClient {
|
2087
|
-
constructor(client, httpRequest) {
|
2088
|
-
__privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
|
2089
|
-
}
|
2090
|
-
/**
|
2091
|
-
* Fetch a user by user ID
|
2092
|
-
*
|
2093
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
2094
|
-
*/
|
2095
|
-
getById(id) {
|
2096
|
-
return lastValueFrom(
|
2097
|
-
_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
2098
|
-
uri: `/users/${id}`
|
2099
|
-
})
|
2100
|
-
);
|
2101
|
-
}
|
2102
|
-
}
|
2103
|
-
_client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
|
2104
|
-
var __accessCheck = (obj, member, msg) => {
|
2105
|
-
if (!member.has(obj))
|
2106
|
-
throw TypeError("Cannot " + msg);
|
2107
|
-
}, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
|
2108
|
-
if (member.has(obj))
|
2109
|
-
throw TypeError("Cannot add the same private member more than once");
|
2110
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2111
|
-
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _clientConfig, _httpRequest;
|
2112
|
-
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
2113
|
-
constructor(httpRequest, config2 = defaultConfig) {
|
2114
|
-
__privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), this.listen = _listen, this.config(config2), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
2115
|
-
}
|
2116
|
-
/**
|
2117
|
-
* Clone the client - returns a new instance
|
2118
|
-
*/
|
2119
|
-
clone() {
|
2120
|
-
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
|
2121
|
-
}
|
2122
|
-
config(newConfig) {
|
2123
|
-
if (newConfig === void 0)
|
2124
|
-
return { ...__privateGet(this, _clientConfig) };
|
2125
|
-
if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
|
2126
|
-
throw new Error(
|
2127
|
-
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
2128
|
-
);
|
2129
|
-
return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
|
2130
|
-
}
|
2131
|
-
/**
|
2132
|
-
* Clone the client with a new (partial) configuration.
|
2133
|
-
*
|
2134
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
2135
|
-
*/
|
2136
|
-
withConfig(newConfig) {
|
2137
|
-
const thisConfig = this.config();
|
2138
|
-
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
|
2139
|
-
...thisConfig,
|
2140
|
-
...newConfig,
|
2141
|
-
stega: {
|
2142
|
-
...thisConfig.stega || {},
|
2143
|
-
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
2144
|
-
}
|
2145
|
-
});
|
2146
|
-
}
|
2147
|
-
fetch(query, params, options) {
|
2148
|
-
return _fetch(
|
2149
|
-
this,
|
2150
|
-
__privateGet(this, _httpRequest),
|
2151
|
-
__privateGet(this, _clientConfig).stega,
|
2152
|
-
query,
|
2153
|
-
params,
|
2154
|
-
options
|
2155
|
-
);
|
2156
|
-
}
|
2157
|
-
/**
|
2158
|
-
* Fetch a single document with the given ID.
|
2159
|
-
*
|
2160
|
-
* @param id - Document ID to fetch
|
2161
|
-
* @param options - Request options
|
2162
|
-
*/
|
2163
|
-
getDocument(id, options) {
|
2164
|
-
return _getDocument(this, __privateGet(this, _httpRequest), id, options);
|
2165
|
-
}
|
2166
|
-
/**
|
2167
|
-
* Fetch multiple documents in one request.
|
2168
|
-
* Should be used sparingly - performing a query is usually a better option.
|
2169
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
2170
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
2171
|
-
*
|
2172
|
-
* @param ids - Document IDs to fetch
|
2173
|
-
* @param options - Request options
|
2174
|
-
*/
|
2175
|
-
getDocuments(ids, options) {
|
2176
|
-
return _getDocuments(this, __privateGet(this, _httpRequest), ids, options);
|
2177
|
-
}
|
2178
|
-
create(document2, options) {
|
2179
|
-
return _create(this, __privateGet(this, _httpRequest), document2, "create", options);
|
2180
|
-
}
|
2181
|
-
createIfNotExists(document2, options) {
|
2182
|
-
return _createIfNotExists(this, __privateGet(this, _httpRequest), document2, options);
|
2183
|
-
}
|
2184
|
-
createOrReplace(document2, options) {
|
2185
|
-
return _createOrReplace(this, __privateGet(this, _httpRequest), document2, options);
|
2186
|
-
}
|
2187
|
-
delete(selection, options) {
|
2188
|
-
return _delete(this, __privateGet(this, _httpRequest), selection, options);
|
2189
|
-
}
|
2190
|
-
mutate(operations, options) {
|
2191
|
-
return _mutate(this, __privateGet(this, _httpRequest), operations, options);
|
2192
|
-
}
|
2193
|
-
/**
|
2194
|
-
* Create a new buildable patch of operations to perform
|
2195
|
-
*
|
2196
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
2197
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
2198
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
2199
|
-
*/
|
2200
|
-
patch(selection, operations) {
|
2201
|
-
return new ObservablePatch(selection, operations, this);
|
2202
|
-
}
|
2203
|
-
/**
|
2204
|
-
* Create a new transaction of mutations
|
2205
|
-
*
|
2206
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
2207
|
-
*/
|
2208
|
-
transaction(operations) {
|
2209
|
-
return new ObservableTransaction(operations, this);
|
2210
|
-
}
|
2211
|
-
/**
|
2212
|
-
* Perform an HTTP request against the Sanity API
|
2213
|
-
*
|
2214
|
-
* @param options - Request options
|
2215
|
-
*/
|
2216
|
-
request(options) {
|
2217
|
-
return _request(this, __privateGet(this, _httpRequest), options);
|
2218
|
-
}
|
2219
|
-
/**
|
2220
|
-
* Get a Sanity API URL for the URI provided
|
2221
|
-
*
|
2222
|
-
* @param uri - URI/path to build URL for
|
2223
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
2224
|
-
*/
|
2225
|
-
getUrl(uri, canUseCdn) {
|
2226
|
-
return _getUrl(this, uri, canUseCdn);
|
2227
|
-
}
|
2228
|
-
/**
|
2229
|
-
* Get a Sanity API URL for the data operation and path provided
|
2230
|
-
*
|
2231
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
2232
|
-
* @param path - Path to append after the operation
|
2233
|
-
*/
|
2234
|
-
getDataUrl(operation, path2) {
|
2235
|
-
return _getDataUrl(this, operation, path2);
|
2236
|
-
}
|
2237
|
-
};
|
2238
|
-
_clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
|
2239
|
-
let ObservableSanityClient = _ObservableSanityClient;
|
2240
|
-
var _clientConfig2, _httpRequest2;
|
2241
|
-
const _SanityClient = class _SanityClient2 {
|
2242
|
-
constructor(httpRequest, config2 = defaultConfig) {
|
2243
|
-
__privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), this.listen = _listen, this.config(config2), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config2);
|
2244
|
-
}
|
2245
|
-
/**
|
2246
|
-
* Clone the client - returns a new instance
|
2247
|
-
*/
|
2248
|
-
clone() {
|
2249
|
-
return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
|
2250
|
-
}
|
2251
|
-
config(newConfig) {
|
2252
|
-
if (newConfig === void 0)
|
2253
|
-
return { ...__privateGet(this, _clientConfig2) };
|
2254
|
-
if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
|
2255
|
-
throw new Error(
|
2256
|
-
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
2257
|
-
);
|
2258
|
-
return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
|
2259
|
-
}
|
2260
|
-
/**
|
2261
|
-
* Clone the client with a new (partial) configuration.
|
2262
|
-
*
|
2263
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
2264
|
-
*/
|
2265
|
-
withConfig(newConfig) {
|
2266
|
-
const thisConfig = this.config();
|
2267
|
-
return new _SanityClient2(__privateGet(this, _httpRequest2), {
|
2268
|
-
...thisConfig,
|
2269
|
-
...newConfig,
|
2270
|
-
stega: {
|
2271
|
-
...thisConfig.stega || {},
|
2272
|
-
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
2273
|
-
}
|
2274
|
-
});
|
2275
|
-
}
|
2276
|
-
fetch(query, params, options) {
|
2277
|
-
return lastValueFrom(
|
2278
|
-
_fetch(
|
2279
|
-
this,
|
2280
|
-
__privateGet(this, _httpRequest2),
|
2281
|
-
__privateGet(this, _clientConfig2).stega,
|
2282
|
-
query,
|
2283
|
-
params,
|
2284
|
-
options
|
2285
|
-
)
|
2286
|
-
);
|
2287
|
-
}
|
2288
|
-
/**
|
2289
|
-
* Fetch a single document with the given ID.
|
2290
|
-
*
|
2291
|
-
* @param id - Document ID to fetch
|
2292
|
-
* @param options - Request options
|
2293
|
-
*/
|
2294
|
-
getDocument(id, options) {
|
2295
|
-
return lastValueFrom(_getDocument(this, __privateGet(this, _httpRequest2), id, options));
|
2296
|
-
}
|
2297
|
-
/**
|
2298
|
-
* Fetch multiple documents in one request.
|
2299
|
-
* Should be used sparingly - performing a query is usually a better option.
|
2300
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
2301
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
2302
|
-
*
|
2303
|
-
* @param ids - Document IDs to fetch
|
2304
|
-
* @param options - Request options
|
2305
|
-
*/
|
2306
|
-
getDocuments(ids, options) {
|
2307
|
-
return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
|
2308
|
-
}
|
2309
|
-
create(document2, options) {
|
2310
|
-
return lastValueFrom(
|
2311
|
-
_create(this, __privateGet(this, _httpRequest2), document2, "create", options)
|
2312
|
-
);
|
2313
|
-
}
|
2314
|
-
createIfNotExists(document2, options) {
|
2315
|
-
return lastValueFrom(
|
2316
|
-
_createIfNotExists(this, __privateGet(this, _httpRequest2), document2, options)
|
2317
|
-
);
|
2318
|
-
}
|
2319
|
-
createOrReplace(document2, options) {
|
2320
|
-
return lastValueFrom(
|
2321
|
-
_createOrReplace(this, __privateGet(this, _httpRequest2), document2, options)
|
2322
|
-
);
|
2323
|
-
}
|
2324
|
-
delete(selection, options) {
|
2325
|
-
return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
|
2326
|
-
}
|
2327
|
-
mutate(operations, options) {
|
2328
|
-
return lastValueFrom(_mutate(this, __privateGet(this, _httpRequest2), operations, options));
|
2329
|
-
}
|
2330
|
-
/**
|
2331
|
-
* Create a new buildable patch of operations to perform
|
2332
|
-
*
|
2333
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
2334
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
2335
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
2336
|
-
*/
|
2337
|
-
patch(documentId, operations) {
|
2338
|
-
return new Patch(documentId, operations, this);
|
2339
|
-
}
|
2340
|
-
/**
|
2341
|
-
* Create a new transaction of mutations
|
2342
|
-
*
|
2343
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
2344
|
-
*/
|
2345
|
-
transaction(operations) {
|
2346
|
-
return new Transaction(operations, this);
|
2347
|
-
}
|
2348
|
-
/**
|
2349
|
-
* Perform a request against the Sanity API
|
2350
|
-
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
2351
|
-
*
|
2352
|
-
* @param options - Request options
|
2353
|
-
* @returns Promise resolving to the response body
|
2354
|
-
*/
|
2355
|
-
request(options) {
|
2356
|
-
return lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
|
2357
|
-
}
|
2358
|
-
/**
|
2359
|
-
* Perform an HTTP request a `/data` sub-endpoint
|
2360
|
-
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
2361
|
-
*
|
2362
|
-
* @deprecated - Use `request()` or your own HTTP library instead
|
2363
|
-
* @param endpoint - Endpoint to hit (mutate, query etc)
|
2364
|
-
* @param body - Request body
|
2365
|
-
* @param options - Request options
|
2366
|
-
* @internal
|
2367
|
-
*/
|
2368
|
-
dataRequest(endpoint, body, options) {
|
2369
|
-
return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
2370
|
-
}
|
2371
|
-
/**
|
2372
|
-
* Get a Sanity API URL for the URI provided
|
2373
|
-
*
|
2374
|
-
* @param uri - URI/path to build URL for
|
2375
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
2376
|
-
*/
|
2377
|
-
getUrl(uri, canUseCdn) {
|
2378
|
-
return _getUrl(this, uri, canUseCdn);
|
2379
|
-
}
|
2380
|
-
/**
|
2381
|
-
* Get a Sanity API URL for the data operation and path provided
|
2382
|
-
*
|
2383
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
2384
|
-
* @param path - Path to append after the operation
|
2385
|
-
*/
|
2386
|
-
getDataUrl(operation, path2) {
|
2387
|
-
return _getDataUrl(this, operation, path2);
|
2388
|
-
}
|
2389
|
-
};
|
2390
|
-
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
2391
|
-
let SanityClient = _SanityClient;
|
2392
|
-
function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
2393
|
-
return { requester: defineHttpRequest(envMiddleware, {}).defaultRequester, createClient: (config2) => new ClassConstructor(
|
2394
|
-
defineHttpRequest(envMiddleware, {
|
2395
|
-
maxRetries: config2.maxRetries,
|
2396
|
-
retryDelay: config2.retryDelay
|
2397
|
-
}),
|
2398
|
-
config2
|
2399
|
-
) };
|
2400
|
-
}
|
2401
|
-
var name$1 = "@sanity/client", version$2 = "6.15.7";
|
2402
|
-
const middleware = [
|
2403
|
-
debug$1({ verbose: !0, namespace: "sanity:client" }),
|
2404
|
-
headers({ "User-Agent": `${name$1} ${version$2}` }),
|
2405
|
-
// Enable keep-alive, and in addition limit the number of sockets that can be opened.
|
2406
|
-
// This avoids opening too many connections to the server if someone tries to execute
|
2407
|
-
// a bunch of requests in parallel. It's recommended to have a concurrency limit
|
2408
|
-
// at a "higher limit" (i.e. you shouldn't actually execute hundreds of requests in parallel),
|
2409
|
-
// and this is mainly to minimize the impact for the network and server.
|
2410
|
-
//
|
2411
|
-
// We're currently matching the same defaults as browsers:
|
2412
|
-
// https://stackoverflow.com/questions/26003756/is-there-a-limit-practical-or-otherwise-to-the-number-of-web-sockets-a-page-op
|
2413
|
-
agent({
|
2414
|
-
keepAlive: !0,
|
2415
|
-
maxSockets: 30,
|
2416
|
-
maxTotalSockets: 256
|
2417
|
-
})
|
2418
|
-
], exp = defineCreateClientExports(middleware, SanityClient), createClient = exp.createClient, requireFunc = typeof __webpack_require__ == "function" ? __non_webpack_require__ : require;
|
2419
|
-
function dynamicRequire(request) {
|
2420
|
-
const mod = requireFunc(request);
|
2421
|
-
return mod.__esModule && mod.default ? mod.default : mod;
|
2422
|
-
}
|
2423
|
-
dynamicRequire.resolve = requireFunc.resolve;
|
2424
|
-
function getCliConfigSync(cwd) {
|
2425
|
-
return getSanityCliConfig(cwd) || getSanityJsonConfig(cwd);
|
2426
|
-
}
|
2427
|
-
function getSanityJsonConfig(cwd) {
|
2428
|
-
const configPath = path$1.join(cwd, "sanity.json");
|
2429
|
-
return fs$1.existsSync(configPath) ? {
|
2430
|
-
config: loadJsonConfig(configPath),
|
2431
|
-
path: configPath,
|
2432
|
-
version: 2
|
2433
|
-
} : null;
|
2434
|
-
}
|
2435
|
-
function getSanityCliConfig(cwd) {
|
2436
|
-
const jsConfigPath = path$1.join(cwd, "sanity.cli.js"), tsConfigPath = path$1.join(cwd, "sanity.cli.ts"), [js, ts] = [fs$1.existsSync(jsConfigPath), fs$1.existsSync(tsConfigPath)];
|
2437
|
-
return !js && !ts ? null : !js && ts ? {
|
2438
|
-
config: importConfig(tsConfigPath),
|
2439
|
-
path: tsConfigPath,
|
2440
|
-
version: 3
|
2441
|
-
} : (js && ts && warn("Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js"), {
|
2442
|
-
config: importConfig(jsConfigPath),
|
2443
|
-
path: jsConfigPath,
|
2444
|
-
version: 3
|
2445
|
-
});
|
2446
|
-
}
|
2447
|
-
function loadJsonConfig(filePath) {
|
2448
|
-
try {
|
2449
|
-
const content = fs$1.readFileSync(filePath, "utf8");
|
2450
|
-
return JSON.parse(content);
|
2451
|
-
} catch (err) {
|
2452
|
-
return console.error(`Error reading "${filePath}": ${err.message}`), null;
|
2453
|
-
}
|
2454
|
-
}
|
2455
|
-
function importConfig(filePath) {
|
2456
|
-
try {
|
2457
|
-
const config2 = dynamicRequire(filePath);
|
2458
|
-
if (config2 === null || typeof config2 != "object")
|
2459
|
-
throw new Error("Module export is not a configuration object");
|
2460
|
-
return "default" in config2 ? config2.default : config2;
|
2461
|
-
} catch (err) {
|
2462
|
-
return err.code === "MODULE_NOT_FOUND" && err.message.includes("sanity/cli") || console.error(`Error reading "${filePath}": ${err.message}`), null;
|
2463
|
-
}
|
2464
|
-
}
|
2465
|
-
function warn(warning) {
|
2466
|
-
typeof process.send == "function" ? process.send({ type: "warning", warning }) : console.warn(warning);
|
2467
|
-
}
|
2468
|
-
function getDefaultExportFromCjs(x) {
|
2469
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
|
2470
|
-
}
|
2471
|
-
var src = { exports: {} }, browser$1 = { exports: {} }, ms, hasRequiredMs;
|
2472
|
-
function requireMs() {
|
2473
|
-
if (hasRequiredMs)
|
2474
|
-
return ms;
|
2475
|
-
hasRequiredMs = 1;
|
2476
|
-
var s2 = 1e3, m = s2 * 60, h = m * 60, d = h * 24, w = d * 7, y = d * 365.25;
|
2477
|
-
ms = function(val, options) {
|
2478
|
-
options = options || {};
|
2479
|
-
var type = typeof val;
|
2480
|
-
if (type === "string" && val.length > 0)
|
2481
|
-
return parse2(val);
|
2482
|
-
if (type === "number" && isFinite(val))
|
2483
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
2484
|
-
throw new Error(
|
2485
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
2486
|
-
);
|
2487
|
-
};
|
2488
|
-
function parse2(str) {
|
2489
|
-
if (str = String(str), !(str.length > 100)) {
|
2490
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
2491
|
-
str
|
2492
|
-
);
|
2493
|
-
if (match) {
|
2494
|
-
var n = parseFloat(match[1]), type = (match[2] || "ms").toLowerCase();
|
2495
|
-
switch (type) {
|
2496
|
-
case "years":
|
2497
|
-
case "year":
|
2498
|
-
case "yrs":
|
2499
|
-
case "yr":
|
2500
|
-
case "y":
|
2501
|
-
return n * y;
|
2502
|
-
case "weeks":
|
2503
|
-
case "week":
|
2504
|
-
case "w":
|
2505
|
-
return n * w;
|
2506
|
-
case "days":
|
2507
|
-
case "day":
|
2508
|
-
case "d":
|
2509
|
-
return n * d;
|
2510
|
-
case "hours":
|
2511
|
-
case "hour":
|
2512
|
-
case "hrs":
|
2513
|
-
case "hr":
|
2514
|
-
case "h":
|
2515
|
-
return n * h;
|
2516
|
-
case "minutes":
|
2517
|
-
case "minute":
|
2518
|
-
case "mins":
|
2519
|
-
case "min":
|
2520
|
-
case "m":
|
2521
|
-
return n * m;
|
2522
|
-
case "seconds":
|
2523
|
-
case "second":
|
2524
|
-
case "secs":
|
2525
|
-
case "sec":
|
2526
|
-
case "s":
|
2527
|
-
return n * s2;
|
2528
|
-
case "milliseconds":
|
2529
|
-
case "millisecond":
|
2530
|
-
case "msecs":
|
2531
|
-
case "msec":
|
2532
|
-
case "ms":
|
2533
|
-
return n;
|
2534
|
-
default:
|
2535
|
-
return;
|
2536
|
-
}
|
2537
|
-
}
|
2538
|
-
}
|
2539
|
-
}
|
2540
|
-
function fmtShort(ms2) {
|
2541
|
-
var msAbs = Math.abs(ms2);
|
2542
|
-
return msAbs >= d ? Math.round(ms2 / d) + "d" : msAbs >= h ? Math.round(ms2 / h) + "h" : msAbs >= m ? Math.round(ms2 / m) + "m" : msAbs >= s2 ? Math.round(ms2 / s2) + "s" : ms2 + "ms";
|
2543
|
-
}
|
2544
|
-
function fmtLong(ms2) {
|
2545
|
-
var msAbs = Math.abs(ms2);
|
2546
|
-
return msAbs >= d ? plural(ms2, msAbs, d, "day") : msAbs >= h ? plural(ms2, msAbs, h, "hour") : msAbs >= m ? plural(ms2, msAbs, m, "minute") : msAbs >= s2 ? plural(ms2, msAbs, s2, "second") : ms2 + " ms";
|
2547
|
-
}
|
2548
|
-
function plural(ms2, msAbs, n, name2) {
|
2549
|
-
var isPlural = msAbs >= n * 1.5;
|
2550
|
-
return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
|
2551
|
-
}
|
2552
|
-
return ms;
|
2553
|
-
}
|
2554
|
-
var common, hasRequiredCommon;
|
2555
|
-
function requireCommon() {
|
2556
|
-
if (hasRequiredCommon)
|
2557
|
-
return common;
|
2558
|
-
hasRequiredCommon = 1;
|
2559
|
-
function setup(env) {
|
2560
|
-
createDebug.debug = createDebug, createDebug.default = createDebug, createDebug.coerce = coerce, createDebug.disable = disable, createDebug.enable = enable, createDebug.enabled = enabled, createDebug.humanize = requireMs(), createDebug.destroy = destroy, Object.keys(env).forEach((key) => {
|
2561
|
-
createDebug[key] = env[key];
|
2562
|
-
}), createDebug.names = [], createDebug.skips = [], createDebug.formatters = {};
|
2563
|
-
function selectColor(namespace) {
|
2564
|
-
let hash = 0;
|
2565
|
-
for (let i = 0; i < namespace.length; i++)
|
2566
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i), hash |= 0;
|
2567
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
2568
|
-
}
|
2569
|
-
createDebug.selectColor = selectColor;
|
2570
|
-
function createDebug(namespace) {
|
2571
|
-
let prevTime, enableOverride = null, namespacesCache, enabledCache;
|
2572
|
-
function debug2(...args) {
|
2573
|
-
if (!debug2.enabled)
|
2574
|
-
return;
|
2575
|
-
const self = debug2, curr = Number(/* @__PURE__ */ new Date()), ms2 = curr - (prevTime || curr);
|
2576
|
-
self.diff = ms2, self.prev = prevTime, self.curr = curr, prevTime = curr, args[0] = createDebug.coerce(args[0]), typeof args[0] != "string" && args.unshift("%O");
|
2577
|
-
let index = 0;
|
2578
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
2579
|
-
if (match === "%%")
|
2580
|
-
return "%";
|
2581
|
-
index++;
|
2582
|
-
const formatter = createDebug.formatters[format];
|
2583
|
-
if (typeof formatter == "function") {
|
2584
|
-
const val = args[index];
|
2585
|
-
match = formatter.call(self, val), args.splice(index, 1), index--;
|
2586
|
-
}
|
2587
|
-
return match;
|
2588
|
-
}), createDebug.formatArgs.call(self, args), (self.log || createDebug.log).apply(self, args);
|
2589
|
-
}
|
2590
|
-
return debug2.namespace = namespace, debug2.useColors = createDebug.useColors(), debug2.color = createDebug.selectColor(namespace), debug2.extend = extend, debug2.destroy = createDebug.destroy, Object.defineProperty(debug2, "enabled", {
|
2591
|
-
enumerable: !0,
|
2592
|
-
configurable: !1,
|
2593
|
-
get: () => enableOverride !== null ? enableOverride : (namespacesCache !== createDebug.namespaces && (namespacesCache = createDebug.namespaces, enabledCache = createDebug.enabled(namespace)), enabledCache),
|
2594
|
-
set: (v) => {
|
2595
|
-
enableOverride = v;
|
2596
|
-
}
|
2597
|
-
}), typeof createDebug.init == "function" && createDebug.init(debug2), debug2;
|
2598
|
-
}
|
2599
|
-
function extend(namespace, delimiter) {
|
2600
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter > "u" ? ":" : delimiter) + namespace);
|
2601
|
-
return newDebug.log = this.log, newDebug;
|
2602
|
-
}
|
2603
|
-
function enable(namespaces) {
|
2604
|
-
createDebug.save(namespaces), createDebug.namespaces = namespaces, createDebug.names = [], createDebug.skips = [];
|
2605
|
-
let i;
|
2606
|
-
const split = (typeof namespaces == "string" ? namespaces : "").split(/[\s,]+/), len = split.length;
|
2607
|
-
for (i = 0; i < len; i++)
|
2608
|
-
split[i] && (namespaces = split[i].replace(/\*/g, ".*?"), namespaces[0] === "-" ? createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")) : createDebug.names.push(new RegExp("^" + namespaces + "$")));
|
2609
|
-
}
|
2610
|
-
function disable() {
|
2611
|
-
const namespaces = [
|
2612
|
-
...createDebug.names.map(toNamespace),
|
2613
|
-
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
2614
|
-
].join(",");
|
2615
|
-
return createDebug.enable(""), namespaces;
|
2616
|
-
}
|
2617
|
-
function enabled(name2) {
|
2618
|
-
if (name2[name2.length - 1] === "*")
|
2619
|
-
return !0;
|
2620
|
-
let i, len;
|
2621
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++)
|
2622
|
-
if (createDebug.skips[i].test(name2))
|
2623
|
-
return !1;
|
2624
|
-
for (i = 0, len = createDebug.names.length; i < len; i++)
|
2625
|
-
if (createDebug.names[i].test(name2))
|
2626
|
-
return !0;
|
2627
|
-
return !1;
|
2628
|
-
}
|
2629
|
-
function toNamespace(regexp) {
|
2630
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
2631
|
-
}
|
2632
|
-
function coerce(val) {
|
2633
|
-
return val instanceof Error ? val.stack || val.message : val;
|
2634
|
-
}
|
2635
|
-
function destroy() {
|
2636
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
2637
|
-
}
|
2638
|
-
return createDebug.enable(createDebug.load()), createDebug;
|
2639
|
-
}
|
2640
|
-
return common = setup, common;
|
2641
|
-
}
|
2642
|
-
var hasRequiredBrowser;
|
2643
|
-
function requireBrowser() {
|
2644
|
-
return hasRequiredBrowser || (hasRequiredBrowser = 1, function(module, exports2) {
|
2645
|
-
exports2.formatArgs = formatArgs, exports2.save = save, exports2.load = load, exports2.useColors = useColors, exports2.storage = localstorage(), exports2.destroy = /* @__PURE__ */ (() => {
|
2646
|
-
let warned = !1;
|
2647
|
-
return () => {
|
2648
|
-
warned || (warned = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
|
2649
|
-
};
|
2650
|
-
})(), exports2.colors = [
|
2651
|
-
"#0000CC",
|
2652
|
-
"#0000FF",
|
2653
|
-
"#0033CC",
|
2654
|
-
"#0033FF",
|
2655
|
-
"#0066CC",
|
2656
|
-
"#0066FF",
|
2657
|
-
"#0099CC",
|
2658
|
-
"#0099FF",
|
2659
|
-
"#00CC00",
|
2660
|
-
"#00CC33",
|
2661
|
-
"#00CC66",
|
2662
|
-
"#00CC99",
|
2663
|
-
"#00CCCC",
|
2664
|
-
"#00CCFF",
|
2665
|
-
"#3300CC",
|
2666
|
-
"#3300FF",
|
2667
|
-
"#3333CC",
|
2668
|
-
"#3333FF",
|
2669
|
-
"#3366CC",
|
2670
|
-
"#3366FF",
|
2671
|
-
"#3399CC",
|
2672
|
-
"#3399FF",
|
2673
|
-
"#33CC00",
|
2674
|
-
"#33CC33",
|
2675
|
-
"#33CC66",
|
2676
|
-
"#33CC99",
|
2677
|
-
"#33CCCC",
|
2678
|
-
"#33CCFF",
|
2679
|
-
"#6600CC",
|
2680
|
-
"#6600FF",
|
2681
|
-
"#6633CC",
|
2682
|
-
"#6633FF",
|
2683
|
-
"#66CC00",
|
2684
|
-
"#66CC33",
|
2685
|
-
"#9900CC",
|
2686
|
-
"#9900FF",
|
2687
|
-
"#9933CC",
|
2688
|
-
"#9933FF",
|
2689
|
-
"#99CC00",
|
2690
|
-
"#99CC33",
|
2691
|
-
"#CC0000",
|
2692
|
-
"#CC0033",
|
2693
|
-
"#CC0066",
|
2694
|
-
"#CC0099",
|
2695
|
-
"#CC00CC",
|
2696
|
-
"#CC00FF",
|
2697
|
-
"#CC3300",
|
2698
|
-
"#CC3333",
|
2699
|
-
"#CC3366",
|
2700
|
-
"#CC3399",
|
2701
|
-
"#CC33CC",
|
2702
|
-
"#CC33FF",
|
2703
|
-
"#CC6600",
|
2704
|
-
"#CC6633",
|
2705
|
-
"#CC9900",
|
2706
|
-
"#CC9933",
|
2707
|
-
"#CCCC00",
|
2708
|
-
"#CCCC33",
|
2709
|
-
"#FF0000",
|
2710
|
-
"#FF0033",
|
2711
|
-
"#FF0066",
|
2712
|
-
"#FF0099",
|
2713
|
-
"#FF00CC",
|
2714
|
-
"#FF00FF",
|
2715
|
-
"#FF3300",
|
2716
|
-
"#FF3333",
|
2717
|
-
"#FF3366",
|
2718
|
-
"#FF3399",
|
2719
|
-
"#FF33CC",
|
2720
|
-
"#FF33FF",
|
2721
|
-
"#FF6600",
|
2722
|
-
"#FF6633",
|
2723
|
-
"#FF9900",
|
2724
|
-
"#FF9933",
|
2725
|
-
"#FFCC00",
|
2726
|
-
"#FFCC33"
|
2727
|
-
];
|
2728
|
-
function useColors() {
|
2729
|
-
return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
2730
|
-
typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
2731
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
2732
|
-
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
2733
|
-
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
2734
|
-
}
|
2735
|
-
function formatArgs(args) {
|
2736
|
-
if (args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff), !this.useColors)
|
2737
|
-
return;
|
2738
|
-
const c2 = "color: " + this.color;
|
2739
|
-
args.splice(1, 0, c2, "color: inherit");
|
2740
|
-
let index = 0, lastC = 0;
|
2741
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
2742
|
-
match !== "%%" && (index++, match === "%c" && (lastC = index));
|
2743
|
-
}), args.splice(lastC, 0, c2);
|
2744
|
-
}
|
2745
|
-
exports2.log = console.debug || console.log || (() => {
|
2746
|
-
});
|
2747
|
-
function save(namespaces) {
|
2748
|
-
try {
|
2749
|
-
namespaces ? exports2.storage.setItem("debug", namespaces) : exports2.storage.removeItem("debug");
|
2750
|
-
} catch {
|
2751
|
-
}
|
2752
|
-
}
|
2753
|
-
function load() {
|
2754
|
-
let r;
|
2755
|
-
try {
|
2756
|
-
r = exports2.storage.getItem("debug");
|
2757
|
-
} catch {
|
2758
|
-
}
|
2759
|
-
return !r && typeof process < "u" && "env" in process && (r = process.env.DEBUG), r;
|
2760
|
-
}
|
2761
|
-
function localstorage() {
|
2762
|
-
try {
|
2763
|
-
return localStorage;
|
2764
|
-
} catch {
|
2765
|
-
}
|
2766
|
-
}
|
2767
|
-
module.exports = requireCommon()(exports2);
|
2768
|
-
const { formatters } = module.exports;
|
2769
|
-
formatters.j = function(v) {
|
2770
|
-
try {
|
2771
|
-
return JSON.stringify(v);
|
2772
|
-
} catch (error) {
|
2773
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
2774
|
-
}
|
2775
|
-
};
|
2776
|
-
}(browser$1, browser$1.exports)), browser$1.exports;
|
2777
|
-
}
|
2778
|
-
var node = { exports: {} }, hasFlag, hasRequiredHasFlag;
|
2779
|
-
function requireHasFlag() {
|
2780
|
-
return hasRequiredHasFlag || (hasRequiredHasFlag = 1, hasFlag = (flag, argv) => {
|
2781
|
-
argv = argv || process.argv;
|
2782
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--", pos = argv.indexOf(prefix + flag), terminatorPos = argv.indexOf("--");
|
2783
|
-
return pos !== -1 && (terminatorPos === -1 ? !0 : pos < terminatorPos);
|
2784
|
-
}), hasFlag;
|
2785
|
-
}
|
2786
|
-
var supportsColor_1, hasRequiredSupportsColor;
|
2787
|
-
function requireSupportsColor() {
|
2788
|
-
if (hasRequiredSupportsColor)
|
2789
|
-
return supportsColor_1;
|
2790
|
-
hasRequiredSupportsColor = 1;
|
2791
|
-
const os2 = require$$0, hasFlag2 = requireHasFlag(), env = process.env;
|
2792
|
-
let forceColor;
|
2793
|
-
hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") ? forceColor = !1 : (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) && (forceColor = !0), "FORCE_COLOR" in env && (forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0);
|
2794
|
-
function translateLevel(level) {
|
2795
|
-
return level === 0 ? !1 : {
|
2796
|
-
level,
|
2797
|
-
hasBasic: !0,
|
2798
|
-
has256: level >= 2,
|
2799
|
-
has16m: level >= 3
|
2800
|
-
};
|
2801
|
-
}
|
2802
|
-
function supportsColor(stream) {
|
2803
|
-
if (forceColor === !1)
|
2804
|
-
return 0;
|
2805
|
-
if (hasFlag2("color=16m") || hasFlag2("color=full") || hasFlag2("color=truecolor"))
|
2806
|
-
return 3;
|
2807
|
-
if (hasFlag2("color=256"))
|
2808
|
-
return 2;
|
2809
|
-
if (stream && !stream.isTTY && forceColor !== !0)
|
2810
|
-
return 0;
|
2811
|
-
const min = forceColor ? 1 : 0;
|
2812
|
-
if (process.platform === "win32") {
|
2813
|
-
const osRelease = os2.release().split(".");
|
2814
|
-
return Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
2815
|
-
}
|
2816
|
-
if ("CI" in env)
|
2817
|
-
return ["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship" ? 1 : min;
|
2818
|
-
if ("TEAMCITY_VERSION" in env)
|
2819
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
2820
|
-
if (env.COLORTERM === "truecolor")
|
2821
|
-
return 3;
|
2822
|
-
if ("TERM_PROGRAM" in env) {
|
2823
|
-
const version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
2824
|
-
switch (env.TERM_PROGRAM) {
|
2825
|
-
case "iTerm.app":
|
2826
|
-
return version2 >= 3 ? 3 : 2;
|
2827
|
-
case "Apple_Terminal":
|
2828
|
-
return 2;
|
2829
|
-
}
|
2830
|
-
}
|
2831
|
-
return /-256(color)?$/i.test(env.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM) || "COLORTERM" in env ? 1 : (env.TERM === "dumb", min);
|
2832
|
-
}
|
2833
|
-
function getSupportLevel(stream) {
|
2834
|
-
const level = supportsColor(stream);
|
2835
|
-
return translateLevel(level);
|
2836
|
-
}
|
2837
|
-
return supportsColor_1 = {
|
2838
|
-
supportsColor: getSupportLevel,
|
2839
|
-
stdout: getSupportLevel(process.stdout),
|
2840
|
-
stderr: getSupportLevel(process.stderr)
|
2841
|
-
}, supportsColor_1;
|
2842
|
-
}
|
2843
|
-
var hasRequiredNode;
|
2844
|
-
function requireNode() {
|
2845
|
-
return hasRequiredNode || (hasRequiredNode = 1, function(module, exports2) {
|
2846
|
-
const tty = require$$0$1, util = require$$1;
|
2847
|
-
exports2.init = init, exports2.log = log, exports2.formatArgs = formatArgs, exports2.save = save, exports2.load = load, exports2.useColors = useColors, exports2.destroy = util.deprecate(
|
2848
|
-
() => {
|
2849
|
-
},
|
2850
|
-
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
2851
|
-
), exports2.colors = [6, 2, 3, 4, 5, 1];
|
2852
|
-
try {
|
2853
|
-
const supportsColor = requireSupportsColor();
|
2854
|
-
supportsColor && (supportsColor.stderr || supportsColor).level >= 2 && (exports2.colors = [
|
2855
|
-
20,
|
2856
|
-
21,
|
2857
|
-
26,
|
2858
|
-
27,
|
2859
|
-
32,
|
2860
|
-
33,
|
2861
|
-
38,
|
2862
|
-
39,
|
2863
|
-
40,
|
2864
|
-
41,
|
2865
|
-
42,
|
2866
|
-
43,
|
2867
|
-
44,
|
2868
|
-
45,
|
2869
|
-
56,
|
2870
|
-
57,
|
2871
|
-
62,
|
2872
|
-
63,
|
2873
|
-
68,
|
2874
|
-
69,
|
2875
|
-
74,
|
2876
|
-
75,
|
2877
|
-
76,
|
2878
|
-
77,
|
2879
|
-
78,
|
2880
|
-
79,
|
2881
|
-
80,
|
2882
|
-
81,
|
2883
|
-
92,
|
2884
|
-
93,
|
2885
|
-
98,
|
2886
|
-
99,
|
2887
|
-
112,
|
2888
|
-
113,
|
2889
|
-
128,
|
2890
|
-
129,
|
2891
|
-
134,
|
2892
|
-
135,
|
2893
|
-
148,
|
2894
|
-
149,
|
2895
|
-
160,
|
2896
|
-
161,
|
2897
|
-
162,
|
2898
|
-
163,
|
2899
|
-
164,
|
2900
|
-
165,
|
2901
|
-
166,
|
2902
|
-
167,
|
2903
|
-
168,
|
2904
|
-
169,
|
2905
|
-
170,
|
2906
|
-
171,
|
2907
|
-
172,
|
2908
|
-
173,
|
2909
|
-
178,
|
2910
|
-
179,
|
2911
|
-
184,
|
2912
|
-
185,
|
2913
|
-
196,
|
2914
|
-
197,
|
2915
|
-
198,
|
2916
|
-
199,
|
2917
|
-
200,
|
2918
|
-
201,
|
2919
|
-
202,
|
2920
|
-
203,
|
2921
|
-
204,
|
2922
|
-
205,
|
2923
|
-
206,
|
2924
|
-
207,
|
2925
|
-
208,
|
2926
|
-
209,
|
2927
|
-
214,
|
2928
|
-
215,
|
2929
|
-
220,
|
2930
|
-
221
|
2931
|
-
]);
|
2932
|
-
} catch {
|
2933
|
-
}
|
2934
|
-
exports2.inspectOpts = Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((obj, key) => {
|
2935
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase());
|
2936
|
-
let val = process.env[key];
|
2937
|
-
return /^(yes|on|true|enabled)$/i.test(val) ? val = !0 : /^(no|off|false|disabled)$/i.test(val) ? val = !1 : val === "null" ? val = null : val = Number(val), obj[prop] = val, obj;
|
2938
|
-
}, {});
|
2939
|
-
function useColors() {
|
2940
|
-
return "colors" in exports2.inspectOpts ? !!exports2.inspectOpts.colors : tty.isatty(process.stderr.fd);
|
2941
|
-
}
|
2942
|
-
function formatArgs(args) {
|
2943
|
-
const { namespace: name2, useColors: useColors2 } = this;
|
2944
|
-
if (useColors2) {
|
2945
|
-
const c2 = this.color, colorCode = "\x1B[3" + (c2 < 8 ? c2 : "8;5;" + c2), prefix = ` ${colorCode};1m${name2} \x1B[0m`;
|
2946
|
-
args[0] = prefix + args[0].split(`
|
2947
|
-
`).join(`
|
2948
|
-
` + prefix), args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
2949
|
-
} else
|
2950
|
-
args[0] = getDate() + name2 + " " + args[0];
|
2951
|
-
}
|
2952
|
-
function getDate() {
|
2953
|
-
return exports2.inspectOpts.hideDate ? "" : (/* @__PURE__ */ new Date()).toISOString() + " ";
|
2954
|
-
}
|
2955
|
-
function log(...args) {
|
2956
|
-
return process.stderr.write(util.format(...args) + `
|
2957
|
-
`);
|
2958
|
-
}
|
2959
|
-
function save(namespaces) {
|
2960
|
-
namespaces ? process.env.DEBUG = namespaces : delete process.env.DEBUG;
|
2961
|
-
}
|
2962
|
-
function load() {
|
2963
|
-
return process.env.DEBUG;
|
2964
|
-
}
|
2965
|
-
function init(debug2) {
|
2966
|
-
debug2.inspectOpts = {};
|
2967
|
-
const keys = Object.keys(exports2.inspectOpts);
|
2968
|
-
for (let i = 0; i < keys.length; i++)
|
2969
|
-
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
2970
|
-
}
|
2971
|
-
module.exports = requireCommon()(exports2);
|
2972
|
-
const { formatters } = module.exports;
|
2973
|
-
formatters.o = function(v) {
|
2974
|
-
return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts).split(`
|
2975
|
-
`).map((str) => str.trim()).join(" ");
|
2976
|
-
}, formatters.O = function(v) {
|
2977
|
-
return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts);
|
2978
|
-
};
|
2979
|
-
}(node, node.exports)), node.exports;
|
2980
|
-
}
|
2981
|
-
typeof process > "u" || process.type === "renderer" || process.browser === !0 || process.__nwjs ? src.exports = requireBrowser() : src.exports = requireNode();
|
2982
|
-
var srcExports = src.exports, debugIt = /* @__PURE__ */ getDefaultExportFromCjs(srcExports);
|
2983
|
-
const debug = debugIt("sanity:cli");
|
2984
|
-
function resolveRootDir(cwd) {
|
2985
|
-
try {
|
2986
|
-
return resolveProjectRoot(cwd) || cwd;
|
2987
|
-
} catch (err) {
|
2988
|
-
throw new Error(`Error occurred trying to resolve project root:
|
2989
|
-
${err.message}`);
|
2990
|
-
}
|
2991
|
-
}
|
2992
|
-
function hasStudioConfig(basePath) {
|
2993
|
-
return [
|
2994
|
-
fileExists(path$1.join(basePath, "sanity.config.js")),
|
2995
|
-
fileExists(path$1.join(basePath, "sanity.config.ts")),
|
2996
|
-
isSanityV2StudioRoot(basePath)
|
2997
|
-
].some(Boolean);
|
2998
|
-
}
|
2999
|
-
function resolveProjectRoot(basePath, iterations = 0) {
|
3000
|
-
if (hasStudioConfig(basePath))
|
3001
|
-
return basePath;
|
3002
|
-
const parentDir = path$1.resolve(basePath, "..");
|
3003
|
-
return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1);
|
3004
|
-
}
|
3005
|
-
function isSanityV2StudioRoot(basePath) {
|
3006
|
-
try {
|
3007
|
-
const content = fs$1.readFileSync(path$1.join(basePath, "sanity.json"), "utf8"), isRoot = !!JSON.parse(content)?.root;
|
3008
|
-
return isRoot && debug("Found Sanity v2 studio root at %s", basePath), isRoot;
|
3009
|
-
} catch {
|
3010
|
-
return !1;
|
3011
|
-
}
|
3012
|
-
}
|
3013
|
-
function fileExists(filePath) {
|
3014
|
-
return fs$1.existsSync(filePath);
|
3015
|
-
}
|
3016
|
-
function getCliClient(options = {}) {
|
3017
|
-
if (typeof process != "object")
|
3018
|
-
throw new Error("getCliClient() should only be called from node.js scripts");
|
3019
|
-
const {
|
3020
|
-
// eslint-disable-next-line no-process-env
|
3021
|
-
cwd = process.env.SANITY_BASE_PATH || process.cwd(),
|
3022
|
-
useCdn = !1,
|
3023
|
-
apiVersion = "2022-06-06",
|
3024
|
-
projectId: projectId2,
|
3025
|
-
dataset: dataset2,
|
3026
|
-
token = getCliClient.__internal__getToken()
|
3027
|
-
} = options;
|
3028
|
-
if (projectId2 && dataset2)
|
3029
|
-
return createClient({ projectId: projectId2, dataset: dataset2, apiVersion, useCdn, token });
|
3030
|
-
const rootDir = resolveRootDir(cwd), { config: config2 } = getCliConfigSync(rootDir) || {};
|
3031
|
-
if (!config2)
|
3032
|
-
throw new Error("Unable to resolve CLI configuration");
|
3033
|
-
const apiConfig = config2?.api || {};
|
3034
|
-
if (!apiConfig.projectId || !apiConfig.dataset)
|
3035
|
-
throw new Error("Unable to resolve project ID/dataset from CLI configuration");
|
3036
|
-
return createClient({
|
3037
|
-
projectId: apiConfig.projectId,
|
3038
|
-
dataset: apiConfig.dataset,
|
3039
|
-
apiVersion,
|
3040
|
-
useCdn,
|
3041
|
-
token
|
3042
|
-
});
|
3043
|
-
}
|
3044
|
-
getCliClient.__internal__getToken = () => {
|
3045
|
-
};
|
3046
|
-
function defineCliConfig(config2) {
|
3047
|
-
return config2;
|
3048
|
-
}
|
3049
|
-
function createCliConfig(config2) {
|
3050
|
-
return config2;
|
3051
|
-
}
|
3052
|
-
var main$1 = { exports: {} }, name = "dotenv", version$1 = "16.3.2", description = "Loads environment variables from .env file", main = "lib/main.js", types = "lib/main.d.ts", exports = {
|
3053
|
-
".": {
|
3054
|
-
types: "./lib/main.d.ts",
|
3055
|
-
require: "./lib/main.js",
|
3056
|
-
default: "./lib/main.js"
|
3057
|
-
},
|
3058
|
-
"./config": "./config.js",
|
3059
|
-
"./config.js": "./config.js",
|
3060
|
-
"./lib/env-options": "./lib/env-options.js",
|
3061
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
3062
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
3063
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
3064
|
-
"./package.json": "./package.json"
|
3065
|
-
}, scripts = {
|
3066
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
3067
|
-
lint: "standard",
|
3068
|
-
"lint-readme": "standard-markdown",
|
3069
|
-
pretest: "npm run lint && npm run dts-check",
|
3070
|
-
test: "tap tests/*.js --100 -Rspec",
|
3071
|
-
prerelease: "npm test",
|
3072
|
-
release: "standard-version"
|
3073
|
-
}, repository = {
|
3074
|
-
type: "git",
|
3075
|
-
url: "git://github.com/motdotla/dotenv.git"
|
3076
|
-
}, funding = "https://github.com/motdotla/dotenv?sponsor=1", keywords = [
|
3077
|
-
"dotenv",
|
3078
|
-
"env",
|
3079
|
-
".env",
|
3080
|
-
"environment",
|
3081
|
-
"variables",
|
3082
|
-
"config",
|
3083
|
-
"settings"
|
3084
|
-
], readmeFilename = "README.md", license = "BSD-2-Clause", devDependencies = {
|
3085
|
-
"@definitelytyped/dtslint": "^0.0.133",
|
3086
|
-
"@types/node": "^18.11.3",
|
3087
|
-
decache: "^4.6.1",
|
3088
|
-
sinon: "^14.0.1",
|
3089
|
-
standard: "^17.0.0",
|
3090
|
-
"standard-markdown": "^7.1.0",
|
3091
|
-
"standard-version": "^9.5.0",
|
3092
|
-
tap: "^16.3.0",
|
3093
|
-
tar: "^6.1.11",
|
3094
|
-
typescript: "^4.8.4"
|
3095
|
-
}, engines = {
|
3096
|
-
node: ">=12"
|
3097
|
-
}, browser = {
|
3098
|
-
fs: !1
|
3099
|
-
}, require$$4 = {
|
3100
|
-
name,
|
3101
|
-
version: version$1,
|
3102
|
-
description,
|
3103
|
-
main,
|
3104
|
-
types,
|
3105
|
-
exports,
|
3106
|
-
scripts,
|
3107
|
-
repository,
|
3108
|
-
funding,
|
3109
|
-
keywords,
|
3110
|
-
readmeFilename,
|
3111
|
-
license,
|
3112
|
-
devDependencies,
|
3113
|
-
engines,
|
3114
|
-
browser
|
3115
|
-
};
|
3116
|
-
const fs = fs$1, path = path$1, os = require$$0, crypto = require$$3, packageJson = require$$4, version = packageJson.version, LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
3117
|
-
function parse(src2) {
|
3118
|
-
const obj = {};
|
3119
|
-
let lines = src2.toString();
|
3120
|
-
lines = lines.replace(/\r\n?/mg, `
|
3121
|
-
`);
|
3122
|
-
let match;
|
3123
|
-
for (; (match = LINE.exec(lines)) != null; ) {
|
3124
|
-
const key = match[1];
|
3125
|
-
let value = match[2] || "";
|
3126
|
-
value = value.trim();
|
3127
|
-
const maybeQuote = value[0];
|
3128
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), maybeQuote === '"' && (value = value.replace(/\\n/g, `
|
3129
|
-
`), value = value.replace(/\\r/g, "\r")), obj[key] = value;
|
3130
|
-
}
|
3131
|
-
return obj;
|
3132
|
-
}
|
3133
|
-
function _parseVault(options) {
|
3134
|
-
const vaultPath = _vaultPath(options), result = DotenvModule.configDotenv({ path: vaultPath });
|
3135
|
-
if (!result.parsed)
|
3136
|
-
throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
3137
|
-
const keys = _dotenvKey(options).split(","), length = keys.length;
|
3138
|
-
let decrypted;
|
3139
|
-
for (let i = 0; i < length; i++)
|
3140
|
-
try {
|
3141
|
-
const key = keys[i].trim(), attrs = _instructions(result, key);
|
3142
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
3143
|
-
break;
|
3144
|
-
} catch (error) {
|
3145
|
-
if (i + 1 >= length)
|
3146
|
-
throw error;
|
3147
|
-
}
|
3148
|
-
return DotenvModule.parse(decrypted);
|
3149
|
-
}
|
3150
|
-
function _log(message) {
|
3151
|
-
console.log(`[dotenv@${version}][INFO] ${message}`);
|
3152
|
-
}
|
3153
|
-
function _warn(message) {
|
3154
|
-
console.log(`[dotenv@${version}][WARN] ${message}`);
|
3155
|
-
}
|
3156
|
-
function _debug(message) {
|
3157
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
3158
|
-
}
|
3159
|
-
function _dotenvKey(options) {
|
3160
|
-
return options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0 ? options.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
|
3161
|
-
}
|
3162
|
-
function _instructions(result, dotenvKey) {
|
3163
|
-
let uri;
|
3164
|
-
try {
|
3165
|
-
uri = new URL(dotenvKey);
|
3166
|
-
} catch (error) {
|
3167
|
-
throw error.code === "ERR_INVALID_URL" ? new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development") : error;
|
3168
|
-
}
|
3169
|
-
const key = uri.password;
|
3170
|
-
if (!key)
|
3171
|
-
throw new Error("INVALID_DOTENV_KEY: Missing key part");
|
3172
|
-
const environment = uri.searchParams.get("environment");
|
3173
|
-
if (!environment)
|
3174
|
-
throw new Error("INVALID_DOTENV_KEY: Missing environment part");
|
3175
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`, ciphertext = result.parsed[environmentKey];
|
3176
|
-
if (!ciphertext)
|
3177
|
-
throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
3178
|
-
return { ciphertext, key };
|
3179
|
-
}
|
3180
|
-
function _vaultPath(options) {
|
3181
|
-
let dotenvPath = path.resolve(process.cwd(), ".env");
|
3182
|
-
return options && options.path && options.path.length > 0 && (dotenvPath = options.path), dotenvPath.endsWith(".vault") ? dotenvPath : `${dotenvPath}.vault`;
|
3183
|
-
}
|
3184
|
-
function _resolveHome(envPath) {
|
3185
|
-
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
3186
|
-
}
|
3187
|
-
function _configVault(options) {
|
3188
|
-
_log("Loading env from encrypted .env.vault");
|
3189
|
-
const parsed = DotenvModule._parseVault(options);
|
3190
|
-
let processEnv = process.env;
|
3191
|
-
return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsed, options), { parsed };
|
3192
|
-
}
|
3193
|
-
function configDotenv(options) {
|
3194
|
-
let dotenvPath = path.resolve(process.cwd(), ".env"), encoding = "utf8";
|
3195
|
-
const debug2 = !!(options && options.debug);
|
3196
|
-
options && (options.path != null && (dotenvPath = _resolveHome(options.path)), options.encoding != null ? encoding = options.encoding : debug2 && _debug("No encoding is specified. UTF-8 is used by default"));
|
3197
|
-
try {
|
3198
|
-
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
|
3199
|
-
let processEnv = process.env;
|
3200
|
-
return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsed, options), { parsed };
|
3201
|
-
} catch (e) {
|
3202
|
-
return debug2 && _debug(`Failed to load ${dotenvPath} ${e.message}`), { error: e };
|
3203
|
-
}
|
3204
|
-
}
|
3205
|
-
function config(options) {
|
3206
|
-
const vaultPath = _vaultPath(options);
|
3207
|
-
return _dotenvKey(options).length === 0 ? DotenvModule.configDotenv(options) : fs.existsSync(vaultPath) ? DotenvModule._configVault(options) : (_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`), DotenvModule.configDotenv(options));
|
3208
|
-
}
|
3209
|
-
function decrypt(encrypted, keyStr) {
|
3210
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
3211
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
3212
|
-
const nonce = ciphertext.subarray(0, 12), authTag = ciphertext.subarray(-16);
|
3213
|
-
ciphertext = ciphertext.subarray(12, -16);
|
3214
|
-
try {
|
3215
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
3216
|
-
return aesgcm.setAuthTag(authTag), `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
3217
|
-
} catch (error) {
|
3218
|
-
const isRange = error instanceof RangeError, invalidKeyLength = error.message === "Invalid key length", decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
3219
|
-
if (isRange || invalidKeyLength) {
|
3220
|
-
const msg = "INVALID_DOTENV_KEY: It must be 64 characters long (or more)";
|
3221
|
-
throw new Error(msg);
|
3222
|
-
} else if (decryptionFailed) {
|
3223
|
-
const msg = "DECRYPTION_FAILED: Please check your DOTENV_KEY";
|
3224
|
-
throw new Error(msg);
|
3225
|
-
} else
|
3226
|
-
throw console.error("Error: ", error.code), console.error("Error: ", error.message), error;
|
3227
|
-
}
|
3228
|
-
}
|
3229
|
-
function populate(processEnv, parsed, options = {}) {
|
3230
|
-
const debug2 = !!(options && options.debug), override = !!(options && options.override);
|
3231
|
-
if (typeof parsed != "object")
|
3232
|
-
throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
3233
|
-
for (const key of Object.keys(parsed))
|
3234
|
-
Object.prototype.hasOwnProperty.call(processEnv, key) ? (override === !0 && (processEnv[key] = parsed[key]), debug2 && _debug(override === !0 ? `"${key}" is already defined and WAS overwritten` : `"${key}" is already defined and was NOT overwritten`)) : processEnv[key] = parsed[key];
|
3235
|
-
}
|
3236
|
-
const DotenvModule = {
|
3237
|
-
configDotenv,
|
3238
|
-
_configVault,
|
3239
|
-
_parseVault,
|
3240
|
-
config,
|
3241
|
-
decrypt,
|
3242
|
-
parse,
|
3243
|
-
populate
|
3244
|
-
};
|
3245
|
-
main$1.exports.configDotenv = DotenvModule.configDotenv;
|
3246
|
-
main$1.exports._configVault = DotenvModule._configVault;
|
3247
|
-
main$1.exports._parseVault = DotenvModule._parseVault;
|
3248
|
-
main$1.exports.config = DotenvModule.config;
|
3249
|
-
main$1.exports.decrypt = DotenvModule.decrypt;
|
3250
|
-
var parse_1 = main$1.exports.parse = DotenvModule.parse;
|
3251
|
-
main$1.exports.populate = DotenvModule.populate;
|
3252
|
-
main$1.exports = DotenvModule;
|
3253
|
-
function _interpolate(envValue, environment, config2) {
|
3254
|
-
const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
|
3255
|
-
return matches.reduce(function(newEnv, match, index) {
|
3256
|
-
const parts = /(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(match);
|
3257
|
-
if (!parts || parts.length === 0)
|
3258
|
-
return newEnv;
|
3259
|
-
const prefix = parts[1];
|
3260
|
-
let value, replacePart;
|
3261
|
-
if (prefix === "\\")
|
3262
|
-
replacePart = parts[0], value = replacePart.replace("\\$", "$");
|
3263
|
-
else {
|
3264
|
-
const keyParts = parts[2].split(":-"), key = keyParts[0];
|
3265
|
-
if (replacePart = parts[0].substring(prefix.length), value = Object.prototype.hasOwnProperty.call(environment, key) ? environment[key] : config2.parsed[key] || keyParts[1] || "", keyParts.length > 1 && value) {
|
3266
|
-
const replaceNested = matches[index + 1];
|
3267
|
-
matches[index + 1] = "", newEnv = newEnv.replace(replaceNested, "");
|
3268
|
-
}
|
3269
|
-
value = _interpolate(value, environment, config2);
|
3270
|
-
}
|
3271
|
-
return newEnv.replace(replacePart, value);
|
3272
|
-
}, envValue);
|
3273
|
-
}
|
3274
|
-
function expand(config2) {
|
3275
|
-
const environment = config2.ignoreProcessEnv ? {} : process.env;
|
3276
|
-
for (const configKey in config2.parsed) {
|
3277
|
-
const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config2.parsed[configKey];
|
3278
|
-
config2.parsed[configKey] = _interpolate(value, environment, config2);
|
3279
|
-
}
|
3280
|
-
for (const processKey in config2.parsed)
|
3281
|
-
environment[processKey] = config2.parsed[processKey];
|
3282
|
-
return config2;
|
3283
|
-
}
|
3284
|
-
var expand_1 = expand;
|
3285
|
-
function loadEnv(mode, envDir, prefixes = ["VITE_"]) {
|
3286
|
-
if (mode === "local")
|
3287
|
-
throw new Error(
|
3288
|
-
'"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.'
|
3289
|
-
);
|
3290
|
-
const env = {}, envFiles = [
|
3291
|
-
/** default file */
|
3292
|
-
".env",
|
3293
|
-
/** local file */
|
3294
|
-
".env.local",
|
3295
|
-
/** mode file */
|
3296
|
-
`.env.${mode}`,
|
3297
|
-
/** mode local file */
|
3298
|
-
`.env.${mode}.local`
|
3299
|
-
], parsed = Object.fromEntries(
|
3300
|
-
envFiles.flatMap((file) => {
|
3301
|
-
const envPath = lookupFile(envDir, [file], {
|
3302
|
-
rootDir: envDir
|
3303
|
-
});
|
3304
|
-
return envPath ? Object.entries(parse_1(fs$2.readFileSync(envPath))) : [];
|
3305
|
-
})
|
3306
|
-
);
|
3307
|
-
parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0 && (process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV), parsed.BROWSER && process.env.BROWSER === void 0 && (process.env.BROWSER = parsed.BROWSER), parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0 && (process.env.BROWSER_ARGS = parsed.BROWSER_ARGS);
|
3308
|
-
try {
|
3309
|
-
expand_1({ parsed });
|
3310
|
-
} catch (e) {
|
3311
|
-
throw e.message.includes("split") ? new Error("dotenv-expand failed to expand env vars. Maybe you need to escape `$`?") : e;
|
3312
|
-
}
|
3313
|
-
for (const [key, value] of Object.entries(parsed))
|
3314
|
-
prefixes.some((prefix) => key.startsWith(prefix)) && (env[key] = value);
|
3315
|
-
for (const key in process.env)
|
3316
|
-
prefixes.some((prefix) => key.startsWith(prefix)) && (env[key] = process.env[key]);
|
3317
|
-
return env;
|
3318
|
-
}
|
3319
|
-
function lookupFile(dir, formats, options) {
|
3320
|
-
for (const format of formats) {
|
3321
|
-
const fullPath = path$2.join(dir, format);
|
3322
|
-
if (fs$2.existsSync(fullPath) && fs$2.statSync(fullPath).isFile())
|
3323
|
-
return fullPath;
|
3324
|
-
}
|
3325
|
-
const parentDir = path$2.dirname(dir);
|
3326
|
-
if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir)))
|
3327
|
-
return lookupFile(parentDir, formats, options);
|
3328
|
-
}
|
3329
|
-
export {
|
3330
|
-
getCliClient as a,
|
3331
|
-
createCliConfig as c,
|
3332
|
-
defineCliConfig as d,
|
3333
|
-
getDefaultExportFromCjs as g,
|
3334
|
-
loadEnv as l
|
3335
|
-
};
|
3336
|
-
//# sourceMappingURL=index.js.map
|