@mountaya/client 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +1260 -2
- package/dist/admin/index.cjs +3521 -0
- package/dist/admin/index.cjs.map +1 -0
- package/dist/admin/index.d.cts +1070 -0
- package/dist/admin/index.d.ts +1070 -0
- package/dist/admin/index.js +301 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/browser.cjs +8073 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +106 -0
- package/dist/browser.d.ts +106 -0
- package/dist/browser.js +53 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-BM526BHG.js +342 -0
- package/dist/chunk-BM526BHG.js.map +1 -0
- package/dist/chunk-D2YEVTG7.js +327 -0
- package/dist/chunk-D2YEVTG7.js.map +1 -0
- package/dist/chunk-OHKVUREN.js +3500 -0
- package/dist/chunk-OHKVUREN.js.map +1 -0
- package/dist/chunk-TDTK2L5H.js +3842 -0
- package/dist/chunk-TDTK2L5H.js.map +1 -0
- package/dist/coreOperations.gen-BMYPoBbz.d.ts +1760 -0
- package/dist/coreOperations.gen-BxX5xRxw.d.cts +1760 -0
- package/dist/errors-B-GqAtQv.d.cts +75960 -0
- package/dist/errors-B-GqAtQv.d.ts +75960 -0
- package/dist/events/index.cjs +1972 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +781 -0
- package/dist/events/index.d.ts +781 -0
- package/dist/events/index.js +826 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.cjs +8072 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +76 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/operations.gen-CvTyzKNF.d.cts +3993 -0
- package/dist/operations.gen-DUD406TV.d.ts +3993 -0
- package/package.json +127 -4
- package/src/admin/index.ts +47 -0
- package/src/admin/rules/mountayaAdmin.ts +102 -0
- package/src/browser.ts +232 -0
- package/src/core/engines/sessionToken.ts +870 -0
- package/src/core/rules/auth.ts +1017 -0
- package/src/core/rules/clientHeader.ts +28 -0
- package/src/core/rules/dates.ts +200 -0
- package/src/core/rules/decode.ts +154 -0
- package/src/core/rules/envelope.ts +41 -0
- package/src/core/rules/errors.ts +1486 -0
- package/src/core/rules/graphql.ts +576 -0
- package/src/core/rules/headerValue.ts +42 -0
- package/src/core/rules/idempotencyKey.ts +64 -0
- package/src/core/rules/nullMask.ts +127 -0
- package/src/core/rules/nullMasks.gen.ts +416 -0
- package/src/core/rules/paginate.ts +316 -0
- package/src/core/rules/rateLimit.ts +507 -0
- package/src/core/rules/redaction.ts +219 -0
- package/src/core/rules/resourceRef.ts +110 -0
- package/src/core/rules/responseBody.ts +492 -0
- package/src/core/rules/retry.ts +386 -0
- package/src/core/rules/selection.ts +416 -0
- package/src/core/rules/sessionAnswer.ts +90 -0
- package/src/core/rules/sessionSchedule.ts +131 -0
- package/src/core/rules/sessionWait.ts +112 -0
- package/src/core/rules/transport.ts +2386 -0
- package/src/core/rules/version.gen.ts +16 -0
- package/src/core/rules/webAddress.ts +165 -0
- package/src/core/rules/webAddresses.gen.ts +30 -0
- package/src/data/operations.gen.ts +603 -0
- package/src/data/schema.gen.ts +8078 -0
- package/src/data/selection.gen.ts +472 -0
- package/src/events/index.ts +67 -0
- package/src/events/rules/agent.ts +439 -0
- package/src/events/rules/collab.ts +554 -0
- package/src/events/rules/collabNulls.gen.ts +17 -0
- package/src/events/rules/eventStream.ts +94 -0
- package/src/events/rules/openSseStream.ts +594 -0
- package/src/events/rules/sse.ts +349 -0
- package/src/index.ts +231 -0
- package/src/rest/adminOperations.gen.ts +70 -0
- package/src/rest/adminResources.gen.ts +136 -0
- package/src/rest/coreOperations.gen.ts +74 -0
- package/src/rest/coreResources.gen.ts +244 -0
- package/src/rest/dates.gen.ts +217 -0
- package/src/rest/operations.gen.ts +4341 -0
- package/src/rest/resources.gen.ts +369 -0
- package/src/rest/schema.gen.ts +56840 -0
- package/src/tiles/operations.gen.ts +206 -0
- package/src/tiles/schema.gen.ts +8408 -0
- package/src/webhooks/rules/constructWebhookEvent.ts +482 -0
- package/src/webhooks/rules/webhookEvent.ts +38 -0
- package/src/webhooks/rules/webhookEvents.gen.ts +732 -0
|
@@ -0,0 +1,3500 @@
|
|
|
1
|
+
import { responseNulls } from './chunk-BM526BHG.js';
|
|
2
|
+
import { readText, readFailureText, parseSuccessBody, decodeSuccessDates, resolveRetry, defaultRetry, isAborted, abortReasonOf, shouldRetry, jitteredDelay, sleep, isKeyInUse, backoffDelay, readFailure, readBytes, KEY_IN_USE_MIN_WAIT_MS, MAX_TIMER_DELAY_MS, isHeaderValue, isEmptyHeaderValue, namedError } from './chunk-D2YEVTG7.js';
|
|
3
|
+
import { __export, postZonePublication, postZoneCollab, postZone, postOrganizationLookup, postItineraryWaypoint, postItineraryShareLinkRotate, postItineraryShareLink, postItinerarySegmentSplit, postItinerarySegmentMerge, postItinerarySegmentGroup, postItinerarySegmentConvert, postItinerarySegment, postItineraryPublication, postItineraryPreview, postItineraryImport, postItineraryDuplicate, postItineraryCollab, postItinerary, postCollectionZones, postCollectionShareLinkRotate, postCollectionShareLink, postCollectionItineraries, postCollection, postAgentRunInput, postAgentRunFeedback, postAgentRun, patchZone, patchItineraryWaypoint, patchItinerarySegmentGroup, patchItinerarySegment, patchItinerary, patchCollectionItinerary, patchCollection, getZones, getZoneEvents, getZone, getOrganizationEvents, getLayers, getItineraryShareLink, getItineraryPace, getItineraryExport, getItineraryEvents, getItinerary, getItineraries, getCollections, getCollectionZones, getCollectionShareLink, getCollectionItineraries, getCollection, getAgentRunEvents, getActivities, deleteZonePublication, deleteZone, deleteItineraryWaypoint, deleteItineraryShareLink, deleteItinerarySegmentGroup, deleteItinerarySegment, deleteItineraryPublication, deleteItinerary, deleteCollectionZone, deleteCollectionShareLink, deleteCollectionItinerary, deleteCollection, parseJsonWithDates, entriesOf, answerDetailsOf, parseRetryAfter, errorForStatus, failureMessage, metadataOf, errorFromBody, statesErrors, MountayaDataError, MountayaError, describeType, MountayaConfigurationError, MountayaConnectionError, withAbsentNulls, replayedOf, refuseOption, MountayaApiError } from './chunk-TDTK2L5H.js';
|
|
4
|
+
|
|
5
|
+
// src/core/rules/auth.ts
|
|
6
|
+
var PUBLISHABLE_PREFIX = "pk_";
|
|
7
|
+
var SECRET_PREFIX = "sk_";
|
|
8
|
+
var SESSION_PREFIX = "sess_";
|
|
9
|
+
var SHARE_PREFIX = "share_";
|
|
10
|
+
var KEY_MEMBERS = ["publishableKey", "secretKey", "sessionToken", "shareToken"];
|
|
11
|
+
var assertHeaderValue = (member, value) => {
|
|
12
|
+
if (isHeaderValue(value) || isEmptyHeaderValue(value)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
throw new MountayaConfigurationError(
|
|
16
|
+
`credential.${member} holds a character no request header carries, since a header carries printable ASCII alone: a line break, a tab or another control character, at either end or inside it, or a character past ASCII, a letter of Latin-1 such as \xE9 among them. ` + (value.includes("\u2026") ? "It reads as a placeholder: replace it with the value your organization was issued." : "Pass it as it was issued, with no line break around it.")
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
var startOf = (value) => `Received a value starting with "${value.slice(0, 3)}".`;
|
|
20
|
+
var assertPrefix = (member, prefix, value, detail) => {
|
|
21
|
+
if (value.startsWith(prefix)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const refusal = `credential.${member} must start with "${prefix}".`;
|
|
25
|
+
throw new MountayaConfigurationError(detail === void 0 ? refusal : `${refusal} ${detail}`);
|
|
26
|
+
};
|
|
27
|
+
var CREDENTIAL_SHAPES = "{ publishableKey } (with a sessionToken where a call needs one), { shareToken } for a share link, { cookie: true } for the browser's own session, or { secretKey } on a server";
|
|
28
|
+
var memberOf = (credential, member) => Reflect.get(credential, member);
|
|
29
|
+
var holdsKey = (credential, member) => {
|
|
30
|
+
const value = memberOf(credential, member);
|
|
31
|
+
return value !== void 0 && !(typeof value === "string" && isEmptyHeaderValue(value));
|
|
32
|
+
};
|
|
33
|
+
var isSecretCredential = (credential) => holdsKey(credential, "secretKey");
|
|
34
|
+
var isShareCredential = (credential) => holdsKey(credential, "shareToken");
|
|
35
|
+
var isPublishableCredential = (credential) => holdsKey(credential, "publishableKey");
|
|
36
|
+
var isCookie = (credential) => memberOf(credential, "cookie") === true && KEY_MEMBERS.every((member) => !holdsKey(credential, member));
|
|
37
|
+
var isSessionTokenSource = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "getSnapshot") === "function" && typeof Reflect.get(value, "subscribe") === "function";
|
|
38
|
+
var assertSourceMembers = (value) => {
|
|
39
|
+
if (typeof value !== "object" || value === null) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!("getSnapshot" in value) && !("subscribe" in value)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const name of ["getSnapshot", "subscribe"]) {
|
|
46
|
+
const found = Reflect.get(value, name);
|
|
47
|
+
if (typeof found !== "function") {
|
|
48
|
+
throw new MountayaConfigurationError(
|
|
49
|
+
`credential.sessionToken.${name} is ${describeType(found)}; a session token source states getSnapshot and subscribe as functions, as a SessionTokenEngine does.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var assertMemberTypes = (credential) => {
|
|
55
|
+
for (const member of KEY_MEMBERS) {
|
|
56
|
+
const value = memberOf(credential, member);
|
|
57
|
+
const readPerRequest = member === "sessionToken" && (typeof value === "function" || isSessionTokenSource(value));
|
|
58
|
+
if (member === "sessionToken" && !readPerRequest) {
|
|
59
|
+
assertSourceMembers(value);
|
|
60
|
+
}
|
|
61
|
+
if (value !== void 0 && typeof value !== "string" && !readPerRequest) {
|
|
62
|
+
throw new MountayaConfigurationError(
|
|
63
|
+
`credential.${member} is ${describeType(value)}; pass it as a string, ` + (member === "sessionToken" ? "a function answering one, or a SessionTokenEngine, " : "") + "or leave it out."
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === "string") {
|
|
67
|
+
if (member === "sessionToken" && isEmptyHeaderValue(value)) {
|
|
68
|
+
throw new MountayaConfigurationError(
|
|
69
|
+
`credential.sessionToken is ${value === "" ? "an empty string" : "whitespace alone"}; pass the token your server minted, or leave it out.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
assertHeaderValue(member, value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const cookie = memberOf(credential, "cookie");
|
|
76
|
+
if (cookie !== void 0 && typeof cookie !== "boolean") {
|
|
77
|
+
throw new MountayaConfigurationError(
|
|
78
|
+
`credential.cookie is ${describeType(cookie)}; pass true to send the browser's own cookies, or leave it out.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var refuseCookieBesideKey = (key) => new MountayaConfigurationError(
|
|
83
|
+
`credential carries ${key} and cookie together, which no credential does: a cookie credential carries no key, and a key credential sends no cookie. Drop cookie to authenticate with the key, or pass { cookie: true } alone to ride the browser's own session.`
|
|
84
|
+
);
|
|
85
|
+
var wantsCookies = (credential) => isCookie(credential) || isShareCredential(credential) && credential.cookie === true;
|
|
86
|
+
var inShippedRuntime = () => {
|
|
87
|
+
if (typeof globalThis !== "object") {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if ("window" in globalThis && "document" in globalThis) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
const runtime = globalThis;
|
|
94
|
+
return runtime.navigator?.product === "ReactNative";
|
|
95
|
+
};
|
|
96
|
+
var assertSessionToken = (token) => {
|
|
97
|
+
assertHeaderValue("sessionToken", token);
|
|
98
|
+
assertPrefix("sessionToken", SESSION_PREFIX, token);
|
|
99
|
+
};
|
|
100
|
+
var sessionTokenOf = (credential) => {
|
|
101
|
+
const member = credential.sessionToken;
|
|
102
|
+
if (member === void 0 || typeof member === "string") {
|
|
103
|
+
return member;
|
|
104
|
+
}
|
|
105
|
+
const answer = typeof member === "function" ? member() : member.getSnapshot().token;
|
|
106
|
+
if (answer === void 0) {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
if (typeof answer !== "string") {
|
|
110
|
+
throw new MountayaConfigurationError(
|
|
111
|
+
`credential.sessionToken answered ${describeType(answer)}; answer the current token as a string, or undefined while there is none.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
assertSessionToken(answer);
|
|
115
|
+
return answer;
|
|
116
|
+
};
|
|
117
|
+
var sessionSourceOf = (credential) => {
|
|
118
|
+
const member = memberOf(credential, "sessionToken");
|
|
119
|
+
return isPublishableCredential(credential) && isSessionTokenSource(member) ? member : void 0;
|
|
120
|
+
};
|
|
121
|
+
var sessionUserOf = (credential) => {
|
|
122
|
+
const source = sessionSourceOf(credential);
|
|
123
|
+
if (source === void 0) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
const user = source.getSnapshot().userId;
|
|
127
|
+
return typeof user === "string" || user === null ? user : void 0;
|
|
128
|
+
};
|
|
129
|
+
var sessionExpiryOf = (credential) => {
|
|
130
|
+
const expiry = sessionSourceOf(credential)?.getSnapshot().expiresAt;
|
|
131
|
+
return expiry instanceof Date && !Number.isNaN(expiry.getTime()) ? expiry : void 0;
|
|
132
|
+
};
|
|
133
|
+
var holdsSession = (credential) => {
|
|
134
|
+
const member = credential.sessionToken;
|
|
135
|
+
if (member === void 0 || typeof member === "string") {
|
|
136
|
+
return member !== void 0;
|
|
137
|
+
}
|
|
138
|
+
if (typeof member === "function") {
|
|
139
|
+
return typeof member() === "string";
|
|
140
|
+
}
|
|
141
|
+
const snapshot = member.getSnapshot();
|
|
142
|
+
return snapshot.token !== void 0 || snapshot.isLoading;
|
|
143
|
+
};
|
|
144
|
+
var assertCredential = (credential) => {
|
|
145
|
+
const value = credential;
|
|
146
|
+
if (typeof value !== "object" || value === null) {
|
|
147
|
+
throw new MountayaConfigurationError(
|
|
148
|
+
`credential is ${describeType(value)}; pass ${CREDENTIAL_SHAPES}.`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
assertMemberTypes(credential);
|
|
152
|
+
if (isSecretCredential(credential)) {
|
|
153
|
+
if (memberOf(credential, "cookie") !== void 0) {
|
|
154
|
+
throw refuseCookieBesideKey("secretKey");
|
|
155
|
+
}
|
|
156
|
+
const beside = KEY_MEMBERS.find(
|
|
157
|
+
(member) => member !== "secretKey" && holdsKey(credential, member)
|
|
158
|
+
);
|
|
159
|
+
if (beside !== void 0) {
|
|
160
|
+
throw new MountayaConfigurationError(
|
|
161
|
+
`credential carries secretKey beside ${beside}, which no credential does: a secret key is sent alone, to postSession. Drop ${beside} to mint sessions with the secret key, or drop secretKey ${beside === "sessionToken" ? "and pass { publishableKey, sessionToken }, since a session token accompanies a publishable key." : `to authenticate with the ${beside}.`}`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
assertPrefix(
|
|
165
|
+
"secretKey",
|
|
166
|
+
SECRET_PREFIX,
|
|
167
|
+
credential.secretKey,
|
|
168
|
+
credential.secretKey.startsWith(PUBLISHABLE_PREFIX) ? "This looks like a publishable key: pass it as { publishableKey }." : (
|
|
169
|
+
// Nothing of the value is quoted: a key pasted without its prefix is still a secret.
|
|
170
|
+
"Pass the secret key as it was issued: nothing of the value is quoted here."
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
if (inShippedRuntime()) {
|
|
174
|
+
throw new MountayaConfigurationError(
|
|
175
|
+
"A secret key must never reach a browser or a mobile application: anyone can read it out of the bundle. Mint a session token on your server with POST /v1/sessions and send that to the client instead."
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (isShareCredential(credential)) {
|
|
181
|
+
assertPrefix("shareToken", SHARE_PREFIX, credential.shareToken);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (isPublishableCredential(credential)) {
|
|
185
|
+
if (memberOf(credential, "cookie") !== void 0) {
|
|
186
|
+
throw refuseCookieBesideKey("publishableKey");
|
|
187
|
+
}
|
|
188
|
+
assertPrefix(
|
|
189
|
+
"publishableKey",
|
|
190
|
+
PUBLISHABLE_PREFIX,
|
|
191
|
+
credential.publishableKey,
|
|
192
|
+
credential.publishableKey.startsWith(SECRET_PREFIX) ? "This looks like a secret key: pass it as { secretKey }, and only from a server." : startOf(credential.publishableKey)
|
|
193
|
+
);
|
|
194
|
+
if (typeof credential.sessionToken === "string") {
|
|
195
|
+
assertSessionToken(credential.sessionToken);
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (memberOf(credential, "cookie") !== void 0) {
|
|
200
|
+
const blank = KEY_MEMBERS.find(
|
|
201
|
+
(member) => member !== "sessionToken" && memberOf(credential, member) !== void 0
|
|
202
|
+
);
|
|
203
|
+
if (blank !== void 0) {
|
|
204
|
+
throw new MountayaConfigurationError(
|
|
205
|
+
`credential carries cookie beside an empty ${blank}, which is how an unset environment variable arrives: set ${blank}, or pass { cookie: true } alone to ride the browser's own session.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (isCookie(credential)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const blanks = KEY_MEMBERS.filter(
|
|
213
|
+
(member) => member !== "sessionToken" && memberOf(credential, member) !== void 0
|
|
214
|
+
).map((member) => `credential.${member}`);
|
|
215
|
+
const blankNote = blanks.length === 0 ? "" : ` (${blanks.join(" and ")} ${blanks.length === 1 ? "is" : "are"} empty or blank, which is how an unset environment variable arrives, and counts as none)`;
|
|
216
|
+
throw new MountayaConfigurationError(
|
|
217
|
+
memberOf(credential, "sessionToken") === void 0 ? `credential carries no publishableKey, secretKey, shareToken or cookie: true${blankNote}, so it authenticates nothing; pass ${CREDENTIAL_SHAPES}.` : "credential carries a sessionToken and no publishableKey, which the session token accompanies rather than replaces; pass { publishableKey, sessionToken }."
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
var subjectOf = (operation) => operation.operationId ?? `A ${operation.method.toUpperCase()}`;
|
|
221
|
+
var isWrite = (operation) => {
|
|
222
|
+
const upper = operation.method.toUpperCase();
|
|
223
|
+
return operation.read !== true && upper !== "GET" && upper !== "HEAD" && upper !== "OPTIONS";
|
|
224
|
+
};
|
|
225
|
+
var credentialHeaders = (credential, operation) => {
|
|
226
|
+
if (operation.takesNoCredential === true) {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
if (isCookie(credential)) {
|
|
230
|
+
return {};
|
|
231
|
+
}
|
|
232
|
+
if (operation.requiresSecretKey === true) {
|
|
233
|
+
if (isSecretCredential(credential)) {
|
|
234
|
+
return { "X-API-Key": credential.secretKey };
|
|
235
|
+
}
|
|
236
|
+
throw new MountayaConfigurationError(
|
|
237
|
+
`${subjectOf(operation)} is authenticated by a secret key alone, which must never reach a browser. Call it on your server with { secretKey }, and give the caller the session token it mints as { publishableKey, sessionToken }.`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
if (isSecretCredential(credential)) {
|
|
241
|
+
throw new MountayaConfigurationError(
|
|
242
|
+
`${subjectOf(operation)} does not take a secret key: a secret key authenticates postSession alone, and the API answers one here with a 401 as if nothing had been sent. ` + (operation.requiresSession !== true ? "Call this one with a publishable key, and keep the secret key on the server that mints sessions." : operation.actsAsMember === true ? "Mint a session token with it on your server, giving postSession's user_id the member this call acts as, and call this one with { publishableKey, sessionToken }." : "Mint a session token with it on your server, and call this one with { publishableKey, sessionToken }.")
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (isShareCredential(credential)) {
|
|
246
|
+
if (operation.acceptsShareToken === true) {
|
|
247
|
+
return { "X-Share-Token": credential.shareToken };
|
|
248
|
+
}
|
|
249
|
+
if (credential.cookie === true && !isWrite(operation)) {
|
|
250
|
+
return {};
|
|
251
|
+
}
|
|
252
|
+
throw new MountayaConfigurationError(
|
|
253
|
+
`${subjectOf(operation)} does not accept a share token. A share token is read-only and reaches the one itinerary, collection or zone it was minted for, through the operations that declare it. ` + (isWrite(operation) ? "Minting, rotating and disabling a share link take a publishable key with the `studio-embedded` scope and a session token minted for `studio-embedded` naming a member with a write role." : "Call this one with a publishable key.")
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const sessionToken = sessionTokenOf(credential);
|
|
257
|
+
if (operation.requiresSession === true && sessionToken === void 0) {
|
|
258
|
+
const forMember = operation.actsAsMember === true ? " This call acts as a member, so mint the token with postSession's user_id set to the user it acts as." : "";
|
|
259
|
+
const source = sessionSourceOf(credential);
|
|
260
|
+
if (source !== void 0) {
|
|
261
|
+
const { error } = source.getSnapshot();
|
|
262
|
+
throw new MountayaConfigurationError(
|
|
263
|
+
`${subjectOf(operation)} requires a session token beside the publishable key, and credential.sessionToken holds none: ` + (error === void 0 ? "no token has been minted, or minting is disabled. " : "its last mint failed, which this error carries as its cause. ") + `Make the call once it holds the token your server minted.${forMember}`,
|
|
264
|
+
error === void 0 ? void 0 : { cause: error }
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
if (typeof credential.sessionToken === "function") {
|
|
268
|
+
throw new MountayaConfigurationError(
|
|
269
|
+
`${subjectOf(operation)} requires a session token beside the publishable key, and credential.sessionToken answered none: no token has been minted yet, or the session has ended. Make the call once it answers the token your server minted.${forMember}`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
throw new MountayaConfigurationError(
|
|
273
|
+
operation.actsAsMember === true ? `${subjectOf(operation)} acts as a member, so it requires a session token minted for that member beside the publishable key. Mint one on your server with POST /v1/sessions, giving user_id the user it acts as, and pass { publishableKey, sessionToken } when constructing the client.` : `${subjectOf(operation)} requires a session token beside the publishable key. Mint one on your server with POST /v1/sessions and pass { publishableKey, sessionToken } when constructing the client.`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
if (operation.actsAsMember === true && sessionToken !== void 0 && sessionUserOf(credential) === null) {
|
|
277
|
+
throw new MountayaConfigurationError(
|
|
278
|
+
`${subjectOf(operation)} acts as the user its session token was minted for, and credential.sessionToken holds a token minted without user_id, which reads and never acts as a member. Mint the token on your server with postSession's user_id set to the user signed in.`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const headers = { "X-API-Key": credential.publishableKey };
|
|
282
|
+
if (sessionToken !== void 0) {
|
|
283
|
+
headers["X-Session-Token"] = sessionToken;
|
|
284
|
+
}
|
|
285
|
+
return headers;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// package.json
|
|
289
|
+
var package_default = {
|
|
290
|
+
version: "0.1.0"
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// src/core/rules/clientHeader.ts
|
|
294
|
+
var CLIENT_VERSION = package_default.version;
|
|
295
|
+
var CLIENT_HEADER_VALUE = `mountaya-typescript/${CLIENT_VERSION}`;
|
|
296
|
+
|
|
297
|
+
// src/core/rules/idempotencyKey.ts
|
|
298
|
+
var randomSource = () => {
|
|
299
|
+
const source = Reflect.get(globalThis, "crypto");
|
|
300
|
+
return typeof source === "object" && source !== null ? source : void 0;
|
|
301
|
+
};
|
|
302
|
+
var uuidOf = (bytes) => {
|
|
303
|
+
bytes[6] = (bytes[6] ?? 0) & 15 | 64;
|
|
304
|
+
bytes[8] = (bytes[8] ?? 0) & 63 | 128;
|
|
305
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
306
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
307
|
+
};
|
|
308
|
+
var mintIdempotencyKey = () => {
|
|
309
|
+
const source = randomSource();
|
|
310
|
+
if (typeof source?.randomUUID === "function") {
|
|
311
|
+
return source.randomUUID().toLowerCase();
|
|
312
|
+
}
|
|
313
|
+
if (typeof source?.getRandomValues === "function") {
|
|
314
|
+
return uuidOf(source.getRandomValues(new Uint8Array(16)));
|
|
315
|
+
}
|
|
316
|
+
return void 0;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// src/core/rules/redaction.ts
|
|
320
|
+
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
321
|
+
var CREDENTIAL_MEMBERS = [
|
|
322
|
+
["cookie"],
|
|
323
|
+
["publishableKey"],
|
|
324
|
+
["secretKey", "sk_"],
|
|
325
|
+
["sessionToken", "sess_"],
|
|
326
|
+
["shareToken", "share_"]
|
|
327
|
+
];
|
|
328
|
+
var redactedSecret = (value, prefix) => value.startsWith(prefix) ? `${prefix}\u2026` : "\u2026";
|
|
329
|
+
var redactedSessionToken = (token) => {
|
|
330
|
+
const [, prefix] = CREDENTIAL_MEMBERS.find(([member]) => member === "sessionToken") ?? [];
|
|
331
|
+
return prefix === void 0 ? "\u2026" : redactedSecret(token, prefix);
|
|
332
|
+
};
|
|
333
|
+
var printedText = (printed) => {
|
|
334
|
+
try {
|
|
335
|
+
return JSON.stringify(printed);
|
|
336
|
+
} catch {
|
|
337
|
+
return "[object Object]";
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
var printsAs = (holder, printed) => Object.defineProperties(holder, {
|
|
341
|
+
[INSPECT]: { value: () => printed(holder) },
|
|
342
|
+
toJSON: { value: () => printed(holder) },
|
|
343
|
+
toString: { value: () => printedText(printed(holder)) }
|
|
344
|
+
});
|
|
345
|
+
var printedSecret = (value, secretPrefix) => {
|
|
346
|
+
if (secretPrefix === void 0) {
|
|
347
|
+
return value;
|
|
348
|
+
}
|
|
349
|
+
if (typeof value === "string") {
|
|
350
|
+
return redactedSecret(value, secretPrefix);
|
|
351
|
+
}
|
|
352
|
+
if (typeof value !== "object" || value === null) {
|
|
353
|
+
return value;
|
|
354
|
+
}
|
|
355
|
+
const getSnapshot = Reflect.get(value, "getSnapshot");
|
|
356
|
+
if (typeof getSnapshot !== "function") {
|
|
357
|
+
return value;
|
|
358
|
+
}
|
|
359
|
+
const snapshot = Reflect.apply(getSnapshot, value, []);
|
|
360
|
+
if (typeof snapshot !== "object" || snapshot === null) {
|
|
361
|
+
return snapshot;
|
|
362
|
+
}
|
|
363
|
+
const token = Reflect.get(snapshot, "token");
|
|
364
|
+
return {
|
|
365
|
+
...snapshot,
|
|
366
|
+
token: typeof token === "string" ? redactedSecret(token, secretPrefix) : token
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
var printedCredential = (credential) => {
|
|
370
|
+
const printed = {};
|
|
371
|
+
for (const [member, secretPrefix] of CREDENTIAL_MEMBERS) {
|
|
372
|
+
const value = Reflect.get(credential, member);
|
|
373
|
+
if (value !== void 0) {
|
|
374
|
+
printed[member] = printedSecret(value, secretPrefix);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return printed;
|
|
378
|
+
};
|
|
379
|
+
var printableCredential = (credential) => {
|
|
380
|
+
const view = {};
|
|
381
|
+
for (const [member] of CREDENTIAL_MEMBERS) {
|
|
382
|
+
Object.defineProperty(view, member, {
|
|
383
|
+
enumerable: true,
|
|
384
|
+
get: () => Reflect.get(credential, member)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return printsAs(view, () => printedCredential(credential));
|
|
388
|
+
};
|
|
389
|
+
var printableProjection = (projection) => printsAs(projection, () => printedCredential(projection));
|
|
390
|
+
var secretDigest = (secret) => {
|
|
391
|
+
let first = 3735928559;
|
|
392
|
+
let second = 1103547991;
|
|
393
|
+
for (let index = 0; index < secret.length; index += 1) {
|
|
394
|
+
const unit = secret.charCodeAt(index);
|
|
395
|
+
first = Math.imul(first ^ unit, 2654435761);
|
|
396
|
+
second = Math.imul(second ^ unit, 1597334677);
|
|
397
|
+
}
|
|
398
|
+
first = Math.imul(first ^ first >>> 16, 2246822507) ^ Math.imul(second ^ second >>> 13, 3266489909);
|
|
399
|
+
second = Math.imul(second ^ second >>> 16, 2246822507) ^ Math.imul(first ^ first >>> 13, 3266489909);
|
|
400
|
+
return (4294967296 * (2097151 & second) + (first >>> 0)).toString(36);
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/core/rules/sessionWait.ts
|
|
404
|
+
var waitForSessionToken = (source, bounds) => {
|
|
405
|
+
const held = source.getSnapshot();
|
|
406
|
+
if (held.token !== void 0 || !held.isLoading) {
|
|
407
|
+
return void 0;
|
|
408
|
+
}
|
|
409
|
+
const { operationId, signal, timeoutMs } = bounds;
|
|
410
|
+
if (signal !== void 0 && isAborted(signal)) {
|
|
411
|
+
return Promise.reject(abortReasonOf(signal));
|
|
412
|
+
}
|
|
413
|
+
return new Promise((resolve, reject) => {
|
|
414
|
+
let ended = false;
|
|
415
|
+
let release;
|
|
416
|
+
let timer;
|
|
417
|
+
const end = (settle) => {
|
|
418
|
+
if (ended) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
ended = true;
|
|
422
|
+
clearTimeout(timer);
|
|
423
|
+
signal?.removeEventListener("abort", onAbort);
|
|
424
|
+
release?.();
|
|
425
|
+
settle();
|
|
426
|
+
};
|
|
427
|
+
const onAbort = () => {
|
|
428
|
+
end(() => {
|
|
429
|
+
reject(signal === void 0 ? void 0 : abortReasonOf(signal));
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
const check = () => {
|
|
433
|
+
const snapshot = source.getSnapshot();
|
|
434
|
+
if (snapshot.token !== void 0 || !snapshot.isLoading) {
|
|
435
|
+
end(resolve);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const unsubscribe = source.subscribe(check);
|
|
439
|
+
if (ended) {
|
|
440
|
+
unsubscribe();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
release = unsubscribe;
|
|
444
|
+
check();
|
|
445
|
+
if (ended) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
449
|
+
timer = setTimeout(() => {
|
|
450
|
+
end(() => {
|
|
451
|
+
reject(
|
|
452
|
+
new MountayaConnectionError(
|
|
453
|
+
`${operationId}: no session token within ${timeoutMs} ms: the session token mint has not answered. Raise timeoutMs, or check the endpoint the mint calls.`
|
|
454
|
+
)
|
|
455
|
+
);
|
|
456
|
+
});
|
|
457
|
+
}, timeoutMs);
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
// src/core/rules/webAddresses.gen.ts
|
|
462
|
+
var requestWebAddresses = {
|
|
463
|
+
/** PATCH /v1/itineraries/{itinerary_id}/waypoints/{waypoint_id} */
|
|
464
|
+
patchItineraryWaypoint: { contact: { booking_url: true, website: true }, media: { links: [{ url: true }], photos: [{ url: true }] } },
|
|
465
|
+
/** PATCH /v1/organizations/{organization_id}/ai-provider-config */
|
|
466
|
+
patchOrganizationAiProviderConfig: { base_url: true },
|
|
467
|
+
/** PATCH /v1/organizations/{organization_id}/webhook-endpoints/{webhook_endpoint_id} */
|
|
468
|
+
patchOrganizationWebhookEndpoint: { url: true },
|
|
469
|
+
/** POST /v1/itineraries/{itinerary_id}/waypoints */
|
|
470
|
+
postItineraryWaypoint: { contact: { booking_url: true, website: true }, media: { links: [{ url: true }], photos: [{ url: true }] } },
|
|
471
|
+
/** POST /v1/organizations */
|
|
472
|
+
postOrganization: { website: true },
|
|
473
|
+
/** POST /v1/organizations/{organization_id}/ai-provider-config */
|
|
474
|
+
postOrganizationAiProviderConfig: { base_url: true },
|
|
475
|
+
/** POST /v1/organizations/{organization_id}/webhook-endpoints */
|
|
476
|
+
postOrganizationWebhookEndpoint: { url: true }
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/core/rules/webAddress.ts
|
|
480
|
+
var absoluteAddressPattern = /^[A-Za-z][A-Za-z0-9+.-]*:[^\n\r\u0085\u2028\u2029]+$/;
|
|
481
|
+
var bareHostPattern = /^(localhost|[a-z0-9-]+(\.[a-z0-9-]+)+)(:\d+)?(\/\S*)?$/i;
|
|
482
|
+
var hasUrlScheme = (text) => absoluteAddressPattern.test(text);
|
|
483
|
+
var isListMask = (mask) => Array.isArray(mask);
|
|
484
|
+
var isList = (value) => Array.isArray(value);
|
|
485
|
+
var schemelessIn = (value, mask, path) => {
|
|
486
|
+
if (mask === true) {
|
|
487
|
+
return typeof value === "string" && !hasUrlScheme(value) ? { path, value } : void 0;
|
|
488
|
+
}
|
|
489
|
+
if (isListMask(mask)) {
|
|
490
|
+
if (!isList(value)) {
|
|
491
|
+
return void 0;
|
|
492
|
+
}
|
|
493
|
+
const [element] = mask;
|
|
494
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
495
|
+
const found = schemelessIn(value[index], element, `${path}[${index}]`);
|
|
496
|
+
if (found !== void 0) {
|
|
497
|
+
return found;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return void 0;
|
|
501
|
+
}
|
|
502
|
+
if (typeof value !== "object" || value === null || isList(value)) {
|
|
503
|
+
return void 0;
|
|
504
|
+
}
|
|
505
|
+
for (const [field, fieldMask] of Object.entries(mask)) {
|
|
506
|
+
if (Object.hasOwn(value, field)) {
|
|
507
|
+
const held = Reflect.get(value, field);
|
|
508
|
+
const found = schemelessIn(held, fieldMask, `${path}.${field}`);
|
|
509
|
+
if (found !== void 0) {
|
|
510
|
+
return found;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return void 0;
|
|
515
|
+
};
|
|
516
|
+
var assertWebAddresses = (operationId, text) => {
|
|
517
|
+
const mask = Object.hasOwn(requestWebAddresses, operationId) ? requestWebAddresses[operationId] : void 0;
|
|
518
|
+
if (mask === void 0) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const found = schemelessIn(JSON.parse(text), mask, "body");
|
|
522
|
+
if (found === void 0) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (found.value.includes("@")) {
|
|
526
|
+
throw new MountayaConfigurationError(
|
|
527
|
+
`${operationId}: ${found.path} is a web address with no scheme, and holds an "@", so its value is not quoted. Pass it with its scheme, such as "https://", since the contract types it an absolute address.`
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
const example = bareHostPattern.test(found.value) ? `"https://${found.value}"` : `"https://" before its host`;
|
|
531
|
+
throw refuseOption(
|
|
532
|
+
found.path,
|
|
533
|
+
found.value,
|
|
534
|
+
`pass it with its scheme, such as ${example}, since the contract types it an absolute address.`,
|
|
535
|
+
operationId
|
|
536
|
+
);
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/core/rules/transport.ts
|
|
540
|
+
var defaultBaseUrls = {
|
|
541
|
+
/** The Data API, stated here since the Data API publishes no server URL to read. */
|
|
542
|
+
data: "https://data.mountaya.com",
|
|
543
|
+
/** The Map Studio REST API, where the event streams are opened too. */
|
|
544
|
+
rest: "https://api.mountaya.com",
|
|
545
|
+
/** The Tile API. */
|
|
546
|
+
tiles: "https://tiles.mountaya.com"
|
|
547
|
+
};
|
|
548
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
549
|
+
var SERVER_BUDGET_MARGIN_MS = 5e3;
|
|
550
|
+
var responseNullMask = (operationId) => (
|
|
551
|
+
// Read as the table's own member alone: an operation id that names a member every object
|
|
552
|
+
// inherits, `toString` among them, names no answer.
|
|
553
|
+
Object.hasOwn(responseNulls, operationId) ? responseNulls[operationId] : void 0
|
|
554
|
+
);
|
|
555
|
+
var isFormData = (body) => typeof FormData !== "undefined" && body instanceof FormData;
|
|
556
|
+
var encodeBody = (body, operationId) => {
|
|
557
|
+
if (body === void 0) {
|
|
558
|
+
return void 0;
|
|
559
|
+
}
|
|
560
|
+
if (isFormData(body)) {
|
|
561
|
+
return body;
|
|
562
|
+
}
|
|
563
|
+
try {
|
|
564
|
+
return JSON.stringify(body);
|
|
565
|
+
} catch (cause) {
|
|
566
|
+
const reason = cause instanceof Error ? cause.message.split("\n", 1)[0] : `threw ${describeType(cause)}`;
|
|
567
|
+
throw new MountayaConfigurationError(
|
|
568
|
+
`${operationId}: the body cannot be sent as JSON (${reason}). Pass a body JSON.stringify accepts, with no cycle and no BigInt.`,
|
|
569
|
+
{ cause }
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
var extendedFilenamePattern = /(?:^|;)[ \t]*filename\*[ \t]*=[ \t]*([^;]*)/i;
|
|
574
|
+
var plainFilenamePattern = /(?:^|;)[ \t]*filename[ \t]*=[ \t]*("(?:[^"\\]|\\.)*"|[^;]*)/i;
|
|
575
|
+
var percentEncodedPattern = /^(?:%[0-9a-f]{2}|[^%])*$/i;
|
|
576
|
+
var decodeExtendedValue = (raw) => {
|
|
577
|
+
const value = raw.trim().replace(/^"(.*)"$/, "$1");
|
|
578
|
+
const charsetEnd = value.indexOf("'");
|
|
579
|
+
const languageEnd = charsetEnd < 0 ? -1 : value.indexOf("'", charsetEnd + 1);
|
|
580
|
+
const charset = languageEnd < 0 ? "utf-8" : value.slice(0, charsetEnd).toLowerCase();
|
|
581
|
+
const encoded = languageEnd < 0 ? value : value.slice(languageEnd + 1);
|
|
582
|
+
if (!percentEncodedPattern.test(encoded)) {
|
|
583
|
+
return void 0;
|
|
584
|
+
}
|
|
585
|
+
if (charset === "iso-8859-1") {
|
|
586
|
+
return encoded.replace(
|
|
587
|
+
/%([0-9a-f]{2})/gi,
|
|
588
|
+
(_escape, byte) => String.fromCharCode(Number.parseInt(byte, 16))
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
if (charset !== "utf-8") {
|
|
592
|
+
return void 0;
|
|
593
|
+
}
|
|
594
|
+
try {
|
|
595
|
+
return decodeURIComponent(encoded);
|
|
596
|
+
} catch {
|
|
597
|
+
return void 0;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
var filenameFromContentDisposition = (header) => {
|
|
601
|
+
if (header === null || header === "") {
|
|
602
|
+
return void 0;
|
|
603
|
+
}
|
|
604
|
+
const extended = extendedFilenamePattern.exec(header)?.[1];
|
|
605
|
+
const decoded = extended === void 0 ? void 0 : decodeExtendedValue(extended);
|
|
606
|
+
if (decoded !== void 0 && decoded !== "") {
|
|
607
|
+
return decoded;
|
|
608
|
+
}
|
|
609
|
+
const plain = plainFilenamePattern.exec(header)?.[1]?.trim() ?? "";
|
|
610
|
+
const quoted = /^"((?:[^"\\]|\\.)*)"$/.exec(plain)?.[1];
|
|
611
|
+
const name = quoted === void 0 ? plain.replace(/^"|"$/g, "") : quoted.replace(/\\(.)/g, "$1");
|
|
612
|
+
return name === "" ? void 0 : name;
|
|
613
|
+
};
|
|
614
|
+
var absoluteUrlPattern = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
615
|
+
var SAME_ORIGIN_BASE = "http://same-origin.invalid";
|
|
616
|
+
var pageOrigin = () => {
|
|
617
|
+
const runtime = globalThis;
|
|
618
|
+
const href = runtime.location?.href;
|
|
619
|
+
if (typeof href !== "string") {
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
let address;
|
|
623
|
+
try {
|
|
624
|
+
address = new URL(href);
|
|
625
|
+
} catch {
|
|
626
|
+
return void 0;
|
|
627
|
+
}
|
|
628
|
+
return address.protocol === "http:" || address.protocol === "https:" ? address.origin : void 0;
|
|
629
|
+
};
|
|
630
|
+
var dotSegmentPattern = /^(?:\.|%2e){1,2}$/i;
|
|
631
|
+
var edgeControlPattern = /^[\0-\x20]+|[\0-\x20]+$/g;
|
|
632
|
+
var refusePath = (path, why, context) => new MountayaConfigurationError(
|
|
633
|
+
`${context === void 0 ? "" : `${context}: `}the path ${JSON.stringify(path)} ${why}`
|
|
634
|
+
);
|
|
635
|
+
var joinUrl = (baseUrl, path, query, context) => {
|
|
636
|
+
const absolute = absoluteUrlPattern.test(baseUrl);
|
|
637
|
+
const base = absolute ? baseUrl : `${SAME_ORIGIN_BASE}${baseUrl.startsWith("/") ? "" : "/"}${baseUrl}`;
|
|
638
|
+
const root = new URL(base.endsWith("/") ? base : `${base}/`);
|
|
639
|
+
const relative = path.replace(edgeControlPattern, "").replace(/[\t\n\r]/g, "").replace(/^[/\\]/, "");
|
|
640
|
+
const written = relative.replace(/[?#].*$/s, "").replaceAll("\\", "/");
|
|
641
|
+
if (written !== "" && written.split("/").some((part) => part === "" || dotSegmentPattern.test(part))) {
|
|
642
|
+
throw refusePath(
|
|
643
|
+
path,
|
|
644
|
+
'holds an empty segment or a dot segment ("." or ".."), which addresses another route than the one written. Pass each identifier as the platform issued it.',
|
|
645
|
+
context
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
const url = new URL(`./${relative}`, root);
|
|
649
|
+
if (!url.href.startsWith(root.href)) {
|
|
650
|
+
throw refusePath(
|
|
651
|
+
path,
|
|
652
|
+
`resolves outside the base URL it is joined onto, so the request would leave the API with the client's credential. Pass a path of the API, starting with one "/".`,
|
|
653
|
+
context
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
if (query !== void 0) {
|
|
657
|
+
for (const [key, value] of Object.entries(query)) {
|
|
658
|
+
if (value !== void 0) {
|
|
659
|
+
url.searchParams.set(key, String(value));
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return absolute ? url.toString() : url.toString().slice(SAME_ORIGIN_BASE.length);
|
|
664
|
+
};
|
|
665
|
+
var buildUrl = (baseUrl, path, query, context) => {
|
|
666
|
+
const joined = joinUrl(baseUrl, path, query, context);
|
|
667
|
+
return absoluteUrlPattern.test(baseUrl) ? joined : `${pageOrigin() ?? ""}${joined}`;
|
|
668
|
+
};
|
|
669
|
+
var isJoinableBase = (base) => {
|
|
670
|
+
if (base === "") {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
if (base.trim() !== base || base.includes("?") || base.includes("#")) {
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
const absolute = absoluteUrlPattern.test(base);
|
|
677
|
+
if (!absolute && (!base.startsWith("/") || base.startsWith("//"))) {
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
let joined;
|
|
681
|
+
try {
|
|
682
|
+
joined = joinUrl(base, "/", void 0);
|
|
683
|
+
} catch {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
if (!absolute) {
|
|
687
|
+
return !joined.startsWith("//");
|
|
688
|
+
}
|
|
689
|
+
const { host, protocol } = new URL(joined);
|
|
690
|
+
return (protocol === "http:" || protocol === "https:") && host !== "";
|
|
691
|
+
};
|
|
692
|
+
var carriesUserinfo = (base) => {
|
|
693
|
+
if (!absoluteUrlPattern.test(base)) {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
try {
|
|
697
|
+
const { password, username } = new URL(base);
|
|
698
|
+
return username !== "" || password !== "";
|
|
699
|
+
} catch {
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var resolveBaseUrls = (baseUrls) => {
|
|
704
|
+
if (baseUrls === void 0) {
|
|
705
|
+
return { ...defaultBaseUrls };
|
|
706
|
+
}
|
|
707
|
+
if (typeof baseUrls !== "object" || baseUrls === null) {
|
|
708
|
+
throw refuseOption(
|
|
709
|
+
"baseUrls",
|
|
710
|
+
baseUrls,
|
|
711
|
+
'pass an object naming a base URL per surface, such as { rest: "http://localhost:8080" }.'
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
const entry = (surface) => {
|
|
715
|
+
const value = baseUrls[surface];
|
|
716
|
+
if (value === void 0) {
|
|
717
|
+
return defaultBaseUrls[surface];
|
|
718
|
+
}
|
|
719
|
+
if (typeof value === "string" && carriesUserinfo(value)) {
|
|
720
|
+
throw new MountayaConfigurationError(
|
|
721
|
+
`baseUrls.${surface} carries a username or a password before its host, which fetch refuses in a request's URL; pass the URL without them, and authenticate through the client's credential.`
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
if (typeof value === "string" && isJoinableBase(value)) {
|
|
725
|
+
if (!absoluteUrlPattern.test(value) && pageOrigin() === void 0) {
|
|
726
|
+
throw new MountayaConfigurationError(
|
|
727
|
+
`baseUrls.${surface} is ${value.includes("@") ? "a path" : JSON.stringify(value)}, a path read against the page's own origin, and no page here names an http or https origin to read it against; pass an http or https URL, such as "https://maps.example.com${value.includes("@") ? "" : value}".`
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
return value;
|
|
731
|
+
}
|
|
732
|
+
if (typeof value === "string" && value.includes("@")) {
|
|
733
|
+
throw new MountayaConfigurationError(
|
|
734
|
+
`baseUrls.${surface} holds an "@" and is no base URL this client can join a path onto, so its value is not quoted: a username or a password may stand before the "@". Pass an http or https URL with no username, password, query or fragment, a path starting with one "/" that does not resolve to "//", or "" for the page's own origin, with no whitespace at either end.`
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
const scheme = typeof value === "string" && bareHostPattern.test(value) ? ` For a host, add its scheme: "https://${value}".` : "";
|
|
738
|
+
throw refuseOption(
|
|
739
|
+
`baseUrls.${surface}`,
|
|
740
|
+
value,
|
|
741
|
+
`pass an http or https URL with no query or fragment, a path starting with one "/" that does not resolve to "//", or "" for the page's own origin, with no whitespace at either end.${scheme}`
|
|
742
|
+
);
|
|
743
|
+
};
|
|
744
|
+
return { data: entry("data"), rest: entry("rest"), tiles: entry("tiles") };
|
|
745
|
+
};
|
|
746
|
+
var resolveTimeout = (timeoutMs, context) => {
|
|
747
|
+
if (timeoutMs === void 0) {
|
|
748
|
+
return DEFAULT_TIMEOUT_MS;
|
|
749
|
+
}
|
|
750
|
+
if (Number.isInteger(timeoutMs) && timeoutMs >= 1 && timeoutMs <= MAX_TIMER_DELAY_MS) {
|
|
751
|
+
return timeoutMs;
|
|
752
|
+
}
|
|
753
|
+
throw refuseOption(
|
|
754
|
+
"timeoutMs",
|
|
755
|
+
timeoutMs,
|
|
756
|
+
context === void 0 ? `pass a whole number of milliseconds from 1 to ${MAX_TIMER_DELAY_MS}, or leave it out for the default of ${DEFAULT_TIMEOUT_MS}.` : `pass a whole number of milliseconds from 1 to ${MAX_TIMER_DELAY_MS}, or leave it out for the client's own.`,
|
|
757
|
+
context
|
|
758
|
+
);
|
|
759
|
+
};
|
|
760
|
+
var NO_LANGUAGE = "*";
|
|
761
|
+
var resolveLanguage = (language) => {
|
|
762
|
+
const given = language;
|
|
763
|
+
if (given === void 0) {
|
|
764
|
+
return void 0;
|
|
765
|
+
}
|
|
766
|
+
if (typeof given === "string" && isHeaderValue(given) && !isEmptyHeaderValue(given)) {
|
|
767
|
+
return given;
|
|
768
|
+
}
|
|
769
|
+
throw refuseOption(
|
|
770
|
+
"language",
|
|
771
|
+
given,
|
|
772
|
+
`pass a BCP 47 tag such as "fr" or "pt-BR", in printable ASCII with no line break around it, or leave it out to send "${NO_LANGUAGE}", which asks for no language in particular.`
|
|
773
|
+
);
|
|
774
|
+
};
|
|
775
|
+
var resolveFetch = (fetchImpl) => {
|
|
776
|
+
const given = fetchImpl;
|
|
777
|
+
if (given !== void 0 && typeof given !== "function") {
|
|
778
|
+
throw refuseOption(
|
|
779
|
+
"fetch",
|
|
780
|
+
given,
|
|
781
|
+
"pass a function that takes what the global fetch takes, or leave it out to call the global one."
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
return boundFetch(fetchImpl);
|
|
785
|
+
};
|
|
786
|
+
var boundFetch = (fetchImpl) => fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
|
|
787
|
+
var attemptSignal = (timeoutMs, caller) => {
|
|
788
|
+
const controller = new AbortController();
|
|
789
|
+
let timedOut = false;
|
|
790
|
+
const timer = setTimeout(() => {
|
|
791
|
+
timedOut = true;
|
|
792
|
+
controller.abort(namedError("TimeoutError", `no response within ${timeoutMs} ms`));
|
|
793
|
+
}, timeoutMs);
|
|
794
|
+
const stopTimer = () => {
|
|
795
|
+
clearTimeout(timer);
|
|
796
|
+
};
|
|
797
|
+
if (caller === void 0) {
|
|
798
|
+
return { release: stopTimer, signal: controller.signal, timedOut: () => timedOut };
|
|
799
|
+
}
|
|
800
|
+
const any = Reflect.get(AbortSignal, "any");
|
|
801
|
+
if (typeof any === "function") {
|
|
802
|
+
return {
|
|
803
|
+
release: stopTimer,
|
|
804
|
+
signal: AbortSignal.any([caller, controller.signal]),
|
|
805
|
+
timedOut: () => timedOut
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
const forward = () => {
|
|
809
|
+
controller.abort(abortReasonOf(caller));
|
|
810
|
+
};
|
|
811
|
+
if (caller.aborted) {
|
|
812
|
+
forward();
|
|
813
|
+
} else {
|
|
814
|
+
caller.addEventListener("abort", forward, { once: true });
|
|
815
|
+
}
|
|
816
|
+
return {
|
|
817
|
+
release: () => {
|
|
818
|
+
stopTimer();
|
|
819
|
+
caller.removeEventListener("abort", forward);
|
|
820
|
+
},
|
|
821
|
+
signal: controller.signal,
|
|
822
|
+
timedOut: () => timedOut
|
|
823
|
+
};
|
|
824
|
+
};
|
|
825
|
+
var refuseEventStream = (args) => {
|
|
826
|
+
const asksForStream = (args.accept ?? "").split(",").some((range) => range.split(";")[0]?.trim().toLowerCase() === "text/event-stream");
|
|
827
|
+
if (!asksForStream) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
const opener = args.operationId === "getAgentRunEvents" ? "createAgentTransport" : args.operationId === "getItineraryEvents" || args.operationId === "getOrganizationEvents" || args.operationId === "getZoneEvents" ? "createCollabTransport" : "openSseStream";
|
|
831
|
+
throw new MountayaConfigurationError(
|
|
832
|
+
`${args.operationId} answers an event stream, which has no end for a request to read to. Open it with ${opener} from @mountaya/client/events, which reads it frame by frame.`
|
|
833
|
+
);
|
|
834
|
+
};
|
|
835
|
+
var discardBody = (response) => {
|
|
836
|
+
const body = response.body;
|
|
837
|
+
if (typeof body?.cancel !== "function") {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
try {
|
|
841
|
+
Promise.resolve(body.cancel()).catch(() => void 0);
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
var resolveServerBudget = (budget, context) => {
|
|
846
|
+
if (budget === void 0) {
|
|
847
|
+
return void 0;
|
|
848
|
+
}
|
|
849
|
+
if (Number.isInteger(budget) && budget >= 1 && budget <= MAX_TIMER_DELAY_MS) {
|
|
850
|
+
return budget;
|
|
851
|
+
}
|
|
852
|
+
throw refuseOption(
|
|
853
|
+
"serverBudgetMs",
|
|
854
|
+
budget,
|
|
855
|
+
`pass the operation's x-timeout-ms, a whole number of milliseconds from 1 to ${MAX_TIMER_DELAY_MS}, or leave it out where it declares none.`,
|
|
856
|
+
context
|
|
857
|
+
);
|
|
858
|
+
};
|
|
859
|
+
var attemptBudget = (clientMs, args) => {
|
|
860
|
+
if (args.timeoutMs !== void 0) {
|
|
861
|
+
return resolveTimeout(args.timeoutMs, args.operationId);
|
|
862
|
+
}
|
|
863
|
+
const server = resolveServerBudget(args.serverBudgetMs, args.operationId);
|
|
864
|
+
return server === void 0 ? clientMs : Math.min(MAX_TIMER_DELAY_MS, Math.max(clientMs, server + SERVER_BUDGET_MARGIN_MS));
|
|
865
|
+
};
|
|
866
|
+
var callerHeaderRemedies = {
|
|
867
|
+
accept: "pass the media type the call answers in, such as application/json, or leave it out for application/json.",
|
|
868
|
+
idempotencyKey: "pass a key of printable ASCII, such as a UUID, or leave it out for the client to draw one.",
|
|
869
|
+
ifMatch: "pass the etag the resource was read under, as the API wrote it, or leave it out for an unconditional write."
|
|
870
|
+
};
|
|
871
|
+
var assertCallerHeader = (member, value, context) => {
|
|
872
|
+
if (value === void 0) {
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (typeof value === "string" && isHeaderValue(value) && !isEmptyHeaderValue(value)) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
throw new MountayaConfigurationError(
|
|
879
|
+
`${context}: ${member} is ${typeof value === "string" ? "a string no request header carries" : describeType(value)}; ${callerHeaderRemedies[member]}`
|
|
880
|
+
);
|
|
881
|
+
};
|
|
882
|
+
var surfaceFault = (fault) => {
|
|
883
|
+
queueMicrotask(() => {
|
|
884
|
+
throw fault;
|
|
885
|
+
});
|
|
886
|
+
};
|
|
887
|
+
var resolveHook = (hook) => {
|
|
888
|
+
const given = hook;
|
|
889
|
+
if (given === void 0 || typeof given === "function") {
|
|
890
|
+
return hook;
|
|
891
|
+
}
|
|
892
|
+
throw refuseOption("onResponse", given, "pass a function told of each answer, or leave it out.");
|
|
893
|
+
};
|
|
894
|
+
var firstCodeOf = (text) => {
|
|
895
|
+
let body;
|
|
896
|
+
try {
|
|
897
|
+
body = JSON.parse(text);
|
|
898
|
+
} catch {
|
|
899
|
+
return void 0;
|
|
900
|
+
}
|
|
901
|
+
return entriesOf(body)[0]?.extensions?.code;
|
|
902
|
+
};
|
|
903
|
+
var rereadable = (response, text) => new Response(text === "" ? null : text, {
|
|
904
|
+
headers: response.headers,
|
|
905
|
+
status: response.status,
|
|
906
|
+
statusText: response.statusText
|
|
907
|
+
});
|
|
908
|
+
var carryingKey = (failure, idempotencyKey) => {
|
|
909
|
+
if (idempotencyKey === void 0) {
|
|
910
|
+
return failure;
|
|
911
|
+
}
|
|
912
|
+
if (failure instanceof MountayaConfigurationError) {
|
|
913
|
+
return new MountayaConfigurationError(failure.message, {
|
|
914
|
+
cause: failure.cause,
|
|
915
|
+
idempotencyKey
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (failure instanceof MountayaConnectionError) {
|
|
919
|
+
return new MountayaConnectionError(failure.message, failure.cause, idempotencyKey);
|
|
920
|
+
}
|
|
921
|
+
return failure;
|
|
922
|
+
};
|
|
923
|
+
var MountayaTransport = class {
|
|
924
|
+
credential;
|
|
925
|
+
baseUrls;
|
|
926
|
+
timeoutMs;
|
|
927
|
+
retry;
|
|
928
|
+
language;
|
|
929
|
+
doFetch;
|
|
930
|
+
credentialsMode;
|
|
931
|
+
onResponse;
|
|
932
|
+
/**
|
|
933
|
+
* Builds a transport over one credential and its options, checking both before anything is
|
|
934
|
+
* sent.
|
|
935
|
+
*
|
|
936
|
+
* @throws `MountayaConfigurationError` for options that are not an object, a credential that
|
|
937
|
+
* cannot work, or an option outside its range: see {@link ClientOptions}.
|
|
938
|
+
*/
|
|
939
|
+
constructor(options) {
|
|
940
|
+
const given = options;
|
|
941
|
+
if (typeof given !== "object" || given === null) {
|
|
942
|
+
throw new MountayaConfigurationError(
|
|
943
|
+
`options is ${describeType(given)}; pass { credential }, with any other option beside it, such as { credential: { publishableKey } }.`
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
assertCredential(options.credential);
|
|
947
|
+
this.credential = printableCredential(options.credential);
|
|
948
|
+
this.credentialsMode = wantsCookies(options.credential) ? "include" : "omit";
|
|
949
|
+
this.baseUrls = resolveBaseUrls(options.baseUrls);
|
|
950
|
+
this.timeoutMs = resolveTimeout(options.timeoutMs);
|
|
951
|
+
this.retry = resolveRetry(defaultRetry, options.retry);
|
|
952
|
+
this.language = resolveLanguage(options.language);
|
|
953
|
+
this.onResponse = resolveHook(options.onResponse);
|
|
954
|
+
this.doFetch = resolveFetch(options.fetch);
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* mapCredential projects the browser-safe half of this transport's credential, for a
|
|
958
|
+
* renderer that has to authenticate requests it makes for itself.
|
|
959
|
+
*
|
|
960
|
+
* `@mountaya/elements` exists because MapLibre fetches tiles, sprites and glyphs on its own
|
|
961
|
+
* schedule, and a credential belongs in a header: the Tile API reads one from the query too,
|
|
962
|
+
* for a request that cannot set a header, and a key in a URL lands in every log, cache and
|
|
963
|
+
* `Referer` that URL reaches. MapLibre's `transformRequest` is the one place to attach a
|
|
964
|
+
* header to a request MapLibre makes. Without this projection a consumer would have to pass
|
|
965
|
+
* their key twice (once to the client, once to the map), and the second copy would drift from
|
|
966
|
+
* the first the moment a session token rotated.
|
|
967
|
+
*
|
|
968
|
+
* **A secret key is never projected**, and that is the whole point of it being a
|
|
969
|
+
* projection rather than a getter for `this.credential`. A secret key mints session
|
|
970
|
+
* tokens and must never reach a browser; a transport built with one yields an empty
|
|
971
|
+
* credential here, so the mistake produces an unauthenticated map rather than a leak.
|
|
972
|
+
*
|
|
973
|
+
* **The cookie flag rides along, and it is not redundant with the browser's own
|
|
974
|
+
* behaviour.** A browser attaches cookies unasked only to a SAME-ORIGIN request; the Tile
|
|
975
|
+
* API is a separate host (`tiles.mountaya.com` by default), so the flag is what becomes
|
|
976
|
+
* `credentials: "include"` on the far side. Dropping it costs a signed-in share-link visitor
|
|
977
|
+
* what their own account reads: the token still authorizes the shared resource, but the
|
|
978
|
+
* API cannot see who is asking, so a signed-in visitor is served the anonymous projection
|
|
979
|
+
* with nothing failing.
|
|
980
|
+
*
|
|
981
|
+
* Which credentials ask for it is `wantsCookies`, the same predicate `credentialsMode`
|
|
982
|
+
* uses above, so a map and a REST call made by one client cannot disagree about it. A
|
|
983
|
+
* publishable key deliberately never carries one: the cookie's broader session would
|
|
984
|
+
* outrank the scoped key.
|
|
985
|
+
*
|
|
986
|
+
* **Every read answers the session token current at that read.** A token held as a function
|
|
987
|
+
* is called here each time, so a renderer that reads the projection per request sends the
|
|
988
|
+
* token current at that request, as a REST call from the same client does. The projection never
|
|
989
|
+
* waits: while a source has its first token on its way, a read answers the key alone, so a
|
|
990
|
+
* tile a map asks for in that window is the anonymous one, and the tiles it asks for once the
|
|
991
|
+
* token lands carry it.
|
|
992
|
+
*
|
|
993
|
+
* **It prints no secret.** A log of the projection, `JSON.stringify` of it and `String` of it show
|
|
994
|
+
* a session token and a share token by their prefix alone (`sess_…`), as the credential the
|
|
995
|
+
* client keeps prints them, and each member still reads whole.
|
|
996
|
+
*
|
|
997
|
+
* @throws `MountayaConfigurationError` where a session token held as a function or a source
|
|
998
|
+
* answers neither a string nor `undefined`, or a string without the `sess_` prefix.
|
|
999
|
+
*/
|
|
1000
|
+
get mapCredential() {
|
|
1001
|
+
const credential = this.credential;
|
|
1002
|
+
const cookie = wantsCookies(credential) ? { cookie: true } : {};
|
|
1003
|
+
if (isShareCredential(credential)) {
|
|
1004
|
+
return printableProjection({ ...cookie, shareToken: credential.shareToken });
|
|
1005
|
+
}
|
|
1006
|
+
if (isPublishableCredential(credential)) {
|
|
1007
|
+
const sessionToken = sessionTokenOf(credential);
|
|
1008
|
+
return printableProjection(
|
|
1009
|
+
sessionToken === void 0 ? { publishableKey: credential.publishableKey } : { publishableKey: credential.publishableKey, sessionToken }
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
return printableProjection(cookie);
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* applyAuth folds this transport's credential into a `RequestInit`, for a call this
|
|
1016
|
+
* client does not make itself.
|
|
1017
|
+
*
|
|
1018
|
+
* Server-sent events are the case it exists for. A stream is a `fetch` the caller owns (it
|
|
1019
|
+
* reads the body rather than awaiting it, reconnects on its own terms, and lives far longer
|
|
1020
|
+
* than a request), so it cannot go through {@link request}. What it must not own is the
|
|
1021
|
+
* credential contract: which header a share token rides in, that a session token
|
|
1022
|
+
* accompanies a publishable key rather than replacing it, that a cookie credential sends
|
|
1023
|
+
* no header and asks for the cookie instead. A host that rebuilds that ladder gets a
|
|
1024
|
+
* ladder that agrees with this one until one of them learns something.
|
|
1025
|
+
*
|
|
1026
|
+
* It stays narrower than a streaming method although two stream vocabularies ARE on the
|
|
1027
|
+
* contract. {@link streamSeam} is what a stream takes from this transport, and the
|
|
1028
|
+
* openers over it live on `@mountaya/client/events` rather than here, so a caller reading
|
|
1029
|
+
* REST and GraphQL never pays for a reader they do not open.
|
|
1030
|
+
*
|
|
1031
|
+
* Caller-supplied headers and init survive: this merges into what it is given, so an
|
|
1032
|
+
* `Accept: text/event-stream` or a `signal` set by the caller is not replaced. `credentials`
|
|
1033
|
+
* is the one member it always writes: `include` for a cookie credential and for a share
|
|
1034
|
+
* credential that states `cookie`, and `omit` for every other, so a key or a bare share token
|
|
1035
|
+
* never travels beside the page's cookies, whatever origin the API is reached at. The client's
|
|
1036
|
+
* `language` rides as `Accept-Language`, `*` where it was given none, as on every request it
|
|
1037
|
+
* makes, so a stream's refusals and the names its events carry come in the language the rest of
|
|
1038
|
+
* the client reads. So does `X-Mountaya-Client`, which names the SDK on every request. Both are
|
|
1039
|
+
* the client's to write: a value the caller's init states for either is replaced.
|
|
1040
|
+
*
|
|
1041
|
+
* The credential is read at each call, a session token held as a function or a source
|
|
1042
|
+
* included, so a stream reopened after the token rotated opens with the current one. It reads
|
|
1043
|
+
* the token held at the call and never waits for one on its way, where a request does.
|
|
1044
|
+
*
|
|
1045
|
+
* `declaration` carries what the call's operation declares, as {@link RequestArgs} does for a
|
|
1046
|
+
* request this client makes, and the same refusals read it: a secret key, which authenticates no
|
|
1047
|
+
* stream, a share token where it does not state `acceptsShareToken`, a credential with no session
|
|
1048
|
+
* token where it states `requiresSession`, and a session source reporting a token minted without
|
|
1049
|
+
* `user_id` where it states `actsAsMember`. Each is a configuration error thrown here, before
|
|
1050
|
+
* anything is opened. The server would answer a share-token write with a 401, or a 400 when
|
|
1051
|
+
* validation fails first, and neither names the rule.
|
|
1052
|
+
*/
|
|
1053
|
+
applyAuth(init = {}, method = "GET", declaration = {}) {
|
|
1054
|
+
const projected = credentialHeaders(this.credential, { ...declaration, method });
|
|
1055
|
+
const headers = new Headers(init.headers);
|
|
1056
|
+
for (const [name, value] of Object.entries(projected)) {
|
|
1057
|
+
headers.set(name, value);
|
|
1058
|
+
}
|
|
1059
|
+
headers.set("Accept-Language", this.language ?? NO_LANGUAGE);
|
|
1060
|
+
headers.set("X-Mountaya-Client", CLIENT_HEADER_VALUE);
|
|
1061
|
+
return { ...init, credentials: this.credentialsMode, headers };
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* streamSeam projects what one `text/event-stream` open needs from this transport: the
|
|
1065
|
+
* credential ladder, the fetch this client resolved, the bound one attempt waits for a
|
|
1066
|
+
* response, and the origin the REST surface is being reached at.
|
|
1067
|
+
*
|
|
1068
|
+
* It exists because a stream cannot go through {@link requestRaw} and the reasons are
|
|
1069
|
+
* structural rather than stylistic. `requestRaw` retries a non-ok status, which for a stream
|
|
1070
|
+
* means silently reopening a feed the caller believes it holds one handle to, and it accepts
|
|
1071
|
+
* no per-call headers, so there is nowhere to put the `Last-Event-ID` a resume rides on.
|
|
1072
|
+
* `requestBinary` is further still: it buffers the whole body, which for a feed with no end
|
|
1073
|
+
* never resolves.
|
|
1074
|
+
*
|
|
1075
|
+
* Handing the seam out rather than opening the stream here is what keeps the reader off
|
|
1076
|
+
* the root barrel's graph. The openers live on `@mountaya/client/events`, so a consumer
|
|
1077
|
+
* reading REST and GraphQL pays nothing for a frame parser they never use, which is the
|
|
1078
|
+
* split the entry point itself exists for.
|
|
1079
|
+
*
|
|
1080
|
+
* `doFetch` is projected rather than kept private because the alternative is worse: the
|
|
1081
|
+
* caller resolving its own, which is precisely the bypass `boundary.test.ts` guards
|
|
1082
|
+
* against. What comes back here is the fetch this transport already uses, so a test
|
|
1083
|
+
* double, an instrumented fetch or a polyfill installed on the client reaches the stream
|
|
1084
|
+
* too. Retry is deliberately NOT part of it: reconnection is a stream's own policy, and
|
|
1085
|
+
* a transport-level retry would reopen a feed behind the caller's back.
|
|
1086
|
+
*/
|
|
1087
|
+
get streamSeam() {
|
|
1088
|
+
return {
|
|
1089
|
+
applyAuth: (init, method, declaration) => this.applyAuth(init, method, declaration),
|
|
1090
|
+
doFetch: this.doFetch,
|
|
1091
|
+
report: (response, operationId) => {
|
|
1092
|
+
this.report(response, { operationId, surface: "rest" }, 0);
|
|
1093
|
+
},
|
|
1094
|
+
sessionExpiresAt: () => sessionExpiryOf(this.credential),
|
|
1095
|
+
sessionUserId: () => sessionUserOf(this.credential),
|
|
1096
|
+
timeoutMs: this.timeoutMs,
|
|
1097
|
+
url: (path, operationId) => buildUrl(this.baseUrls.rest, path, void 0, operationId),
|
|
1098
|
+
waitForSession: (operationId, signal) => {
|
|
1099
|
+
const source = sessionSourceOf(this.credential);
|
|
1100
|
+
return source === void 0 ? void 0 : waitForSessionToken(source, { operationId, signal, timeoutMs: this.timeoutMs });
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* credentialScope identifies WHICH credential this transport holds and WHO it acts as, for a
|
|
1106
|
+
* cache key.
|
|
1107
|
+
*
|
|
1108
|
+
* One query cache usually serves a whole application, so a resource read under one
|
|
1109
|
+
* credential and the same resource read under another land on one entry unless something
|
|
1110
|
+
* separates them. That is wrong twice over, and the second way is a security property
|
|
1111
|
+
* rather than a correctness one: a share link uses its first read as the token's
|
|
1112
|
+
* AUTHORIZATION PROBE, so an entry seeded by a different credential would let a rotated
|
|
1113
|
+
* or foreign token resolve out of cache without ever reaching the API.
|
|
1114
|
+
*
|
|
1115
|
+
* The share token is part of the value for exactly that reason, by a digest of it: two
|
|
1116
|
+
* successive tokens for one resource are the case the probe exists to separate, and keying on
|
|
1117
|
+
* the kind alone would collapse them. A digest names a token without holding it, so a query key
|
|
1118
|
+
* that devtools show, a cache persisted to storage or a key written to a log carries no secret,
|
|
1119
|
+
* and the same token is named alike on a server and in the page it renders.
|
|
1120
|
+
*
|
|
1121
|
+
* Under a publishable key, the session is part of the value, since the session token names the
|
|
1122
|
+
* user a request acts as and what a member reads is theirs:
|
|
1123
|
+
*
|
|
1124
|
+
* - a token held by a source that reports the user it was minted for, as a
|
|
1125
|
+
* `SessionTokenEngine` does, is keyed by that user, `user:<id>`, or as one minted without
|
|
1126
|
+
* `user_id`, so a page whose person signs out or switches account serves nobody what the
|
|
1127
|
+
* person before them read, and a token the source rotates for the same person keeps the
|
|
1128
|
+
* entries;
|
|
1129
|
+
* - a token held as a string is keyed by a digest of the token, since the client is not told
|
|
1130
|
+
* whom it names and it never rotates, and a key never holds the token itself;
|
|
1131
|
+
* - a token held as a function, or by a source that reports no user, is keyed by its presence
|
|
1132
|
+
* alone, since its value rotates and folding it in would evict the whole cache every refresh
|
|
1133
|
+
* to distinguish a credential from itself. Present means a request made now carries a token
|
|
1134
|
+
* or waits for one, which a source reports from construction until its mint answers.
|
|
1135
|
+
*
|
|
1136
|
+
* An answer read under the key alone (a server prefetch, a failed mint, a sign-out) is the
|
|
1137
|
+
* anonymous projection, keyed apart from every session. A secret key is named by its kind
|
|
1138
|
+
* alone, and the browser's own session as `cookie`. {@link subscribeCredentialScope} tells a
|
|
1139
|
+
* listener each time the value moves.
|
|
1140
|
+
*
|
|
1141
|
+
* Before a source's first token lands, the value names the session's presence and not yet its
|
|
1142
|
+
* user, and {@link credentialScopePending} is true: a cache holds its reads until it turns
|
|
1143
|
+
* false, so each one is keyed once, under the user the token names.
|
|
1144
|
+
*
|
|
1145
|
+
* Every member is written so that no space stands inside it, a key and a user escaped and a
|
|
1146
|
+
* secret digested, so the space between two members cannot come from inside one. Opaque by
|
|
1147
|
+
* contract. Compare it, do not parse it.
|
|
1148
|
+
*
|
|
1149
|
+
* @throws what a session token held as a function throws, since the function is called here.
|
|
1150
|
+
*/
|
|
1151
|
+
get credentialScope() {
|
|
1152
|
+
const credential = this.credential;
|
|
1153
|
+
if (isShareCredential(credential)) {
|
|
1154
|
+
return `share:${secretDigest(credential.shareToken)}`;
|
|
1155
|
+
}
|
|
1156
|
+
if (isSecretCredential(credential)) {
|
|
1157
|
+
return "secret";
|
|
1158
|
+
}
|
|
1159
|
+
if (!isPublishableCredential(credential)) {
|
|
1160
|
+
return "cookie";
|
|
1161
|
+
}
|
|
1162
|
+
const key = `key:${encodeURIComponent(credential.publishableKey)}`;
|
|
1163
|
+
if (!holdsSession(credential)) {
|
|
1164
|
+
return key;
|
|
1165
|
+
}
|
|
1166
|
+
const member = credential.sessionToken;
|
|
1167
|
+
if (typeof member === "string") {
|
|
1168
|
+
return `${key} session:${secretDigest(member)}`;
|
|
1169
|
+
}
|
|
1170
|
+
const user = sessionUserOf(credential);
|
|
1171
|
+
if (user === null) {
|
|
1172
|
+
return `${key} session nobody`;
|
|
1173
|
+
}
|
|
1174
|
+
return user === void 0 ? `${key} session` : `${key} session user:${encodeURIComponent(user)}`;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* credentialScopePending reports whether {@link credentialScope} is still to be told who the
|
|
1178
|
+
* session acts as: the credential's {@link SessionTokenSource} holds no token and reports one
|
|
1179
|
+
* on its way, which it does from its construction until its first mint answers, and again
|
|
1180
|
+
* after a sign-out while the next person's mint is out.
|
|
1181
|
+
*
|
|
1182
|
+
* While it is true, the scope names a session and no user yet, and the token that lands names
|
|
1183
|
+
* the user a request made now acts as. That landing refines the scope of the same credential
|
|
1184
|
+
* rather than replacing it, so a query cache holds every read keyed by the scope until this
|
|
1185
|
+
* turns false, and keys each read once, under the scope the token settles. Holding them costs
|
|
1186
|
+
* no time: a request made now waits for that token anyway.
|
|
1187
|
+
*
|
|
1188
|
+
* False for every other credential and state: a token held as a string or a function, a source
|
|
1189
|
+
* that holds a token (a refresh in flight included), a source whose mint failed or that is
|
|
1190
|
+
* disabled, a key alone, a secret key, a share token and the browser's own session.
|
|
1191
|
+
* {@link subscribeCredentialScope} tells a listener each time it moves.
|
|
1192
|
+
*/
|
|
1193
|
+
get credentialScopePending() {
|
|
1194
|
+
const source = sessionSourceOf(this.credential);
|
|
1195
|
+
if (source === void 0) {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
const snapshot = source.getSnapshot();
|
|
1199
|
+
return snapshot.token === void 0 && snapshot.isLoading;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* subscribeCredentialScope registers a listener told each time {@link credentialScope} or
|
|
1203
|
+
* {@link credentialScopePending} moves, and returns its release.
|
|
1204
|
+
*
|
|
1205
|
+
* Both move where the credential's {@link SessionTokenSource} does: a first mint that lands, a
|
|
1206
|
+
* sign-out that clears the token, a mint for another person. A refresh for the same person
|
|
1207
|
+
* moves neither. The listener reads them both, and {@link actsAsMember}, which moves with them.
|
|
1208
|
+
* A credential with no source never moves, and its release does nothing. Subscribing holds the
|
|
1209
|
+
* source as any subscriber does, so an engine nobody held yet starts its mint. A fault the
|
|
1210
|
+
* listener throws reaches the runtime as the program's own uncaught error, on a microtask, and
|
|
1211
|
+
* every later move is still told.
|
|
1212
|
+
*
|
|
1213
|
+
* @param listener - Called with no argument after each move of the scope or of its pending flag.
|
|
1214
|
+
* @returns The function that removes the listener.
|
|
1215
|
+
*/
|
|
1216
|
+
subscribeCredentialScope(listener) {
|
|
1217
|
+
const source = sessionSourceOf(this.credential);
|
|
1218
|
+
if (source === void 0) {
|
|
1219
|
+
return () => void 0;
|
|
1220
|
+
}
|
|
1221
|
+
let lastScope = this.credentialScope;
|
|
1222
|
+
let lastPending = this.credentialScopePending;
|
|
1223
|
+
return source.subscribe(() => {
|
|
1224
|
+
const scope = this.credentialScope;
|
|
1225
|
+
const pending = this.credentialScopePending;
|
|
1226
|
+
if (scope === lastScope && pending === lastPending) {
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
lastScope = scope;
|
|
1230
|
+
lastPending = pending;
|
|
1231
|
+
try {
|
|
1232
|
+
listener();
|
|
1233
|
+
} catch (fault) {
|
|
1234
|
+
surfaceFault(fault);
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* actsAsMember reports whether a call that acts as a member can be made under this transport's
|
|
1240
|
+
* credential now, as far as the client is told: `true` where its session source reports a token
|
|
1241
|
+
* minted for a user, `false` where it reports one minted without `user_id`, and where the
|
|
1242
|
+
* credential carries no session token at all (a bare publishable key, a secret key, a share token), and
|
|
1243
|
+
* undefined where the client is not told, as under a token held as a string or a function, a
|
|
1244
|
+
* source that reports no user, or the browser's own session.
|
|
1245
|
+
*
|
|
1246
|
+
* It is the question a surface that writes asks to decide whether to offer its writes: `false`
|
|
1247
|
+
* means every call that acts as a member is refused before it is sent. Read it again when
|
|
1248
|
+
* {@link subscribeCredentialScope} reports a move.
|
|
1249
|
+
*/
|
|
1250
|
+
get actsAsMember() {
|
|
1251
|
+
const credential = this.credential;
|
|
1252
|
+
if (isSecretCredential(credential) || isShareCredential(credential)) {
|
|
1253
|
+
return false;
|
|
1254
|
+
}
|
|
1255
|
+
if (!isPublishableCredential(credential)) {
|
|
1256
|
+
return void 0;
|
|
1257
|
+
}
|
|
1258
|
+
if (credential.sessionToken === void 0) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
const user = sessionUserOf(credential);
|
|
1262
|
+
return user === void 0 ? void 0 : user !== null;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* reachesSessionOperations reports whether this transport can make the operations that require
|
|
1266
|
+
* a session token: every Data API request, and every `management` and `studio-embedded`
|
|
1267
|
+
* operation of the Map Studio API, the writes and the collaboration and agent streams among them.
|
|
1268
|
+
*
|
|
1269
|
+
* It answers for the credential's shape and never for a token: true under a publishable key
|
|
1270
|
+
* given a `sessionToken` in any form (a string, a function or a source, whether or not it holds
|
|
1271
|
+
* a token at this moment), and under the browser's own session, which those refusals do not
|
|
1272
|
+
* read; false under a publishable key given no session token, a secret key and a share token,
|
|
1273
|
+
* each of which is refused such an operation before anything is sent. A function is not called
|
|
1274
|
+
* and a source is not read, so a session whose first mint is still out, or whose last mint
|
|
1275
|
+
* failed, reaches them here, and the request itself waits for its token or is refused for want
|
|
1276
|
+
* of one.
|
|
1277
|
+
*
|
|
1278
|
+
* It is the question a surface that writes asks at configuration time, where the answer false
|
|
1279
|
+
* means none of its writes can ever leave the process.
|
|
1280
|
+
*/
|
|
1281
|
+
get reachesSessionOperations() {
|
|
1282
|
+
const credential = this.credential;
|
|
1283
|
+
if (isSecretCredential(credential) || isShareCredential(credential)) {
|
|
1284
|
+
return false;
|
|
1285
|
+
}
|
|
1286
|
+
return isPublishableCredential(credential) ? credential.sessionToken !== void 0 : true;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* tilesBaseUrl is the origin the Tile API is being reached at.
|
|
1290
|
+
*
|
|
1291
|
+
* A renderer needs it to decide which of MapLibre's many requests get the credential
|
|
1292
|
+
* attached: `transformRequest` is called for every request including third-party
|
|
1293
|
+
* basemaps and fonts, so the allowlist is the security boundary, not a nicety. Reading it
|
|
1294
|
+
* from here rather than defaulting to the public host is what keeps a map pointed at a
|
|
1295
|
+
* local stack or a proxy authenticating correctly.
|
|
1296
|
+
*/
|
|
1297
|
+
get tilesBaseUrl() {
|
|
1298
|
+
return this.baseUrls.tiles;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* restBaseUrl is the address the Map Studio API is being reached at, as the client was given it
|
|
1302
|
+
* or its default.
|
|
1303
|
+
*
|
|
1304
|
+
* A read shared across clients is shared only between clients that send to the same API: a
|
|
1305
|
+
* client pointed at a staging stack and another at production may hold the same publishable
|
|
1306
|
+
* key, and an answer one of them read is no answer for the other.
|
|
1307
|
+
*/
|
|
1308
|
+
get restBaseUrl() {
|
|
1309
|
+
return this.baseUrls.rest;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* requestLanguage is the language this transport was given, which it sends as
|
|
1313
|
+
* `Accept-Language`, or undefined where it was given none and sends `*`, which asks for no
|
|
1314
|
+
* language in particular.
|
|
1315
|
+
*
|
|
1316
|
+
* The third member of the projection `mapCredential` and `tilesBaseUrl` belong to, and it
|
|
1317
|
+
* exists for the same reason they do: tile labels and legends are localized server-side,
|
|
1318
|
+
* so a renderer that does not state a language is labelled in whatever the browser
|
|
1319
|
+
* happens to prefer while every REST message beside it comes back in the client's. One
|
|
1320
|
+
* itinerary, two languages, and nothing failing.
|
|
1321
|
+
*
|
|
1322
|
+
* A getter rather than a second `language` option on the map, because the two could then
|
|
1323
|
+
* disagree, and the one a reader would blame is not the one that would be wrong.
|
|
1324
|
+
*/
|
|
1325
|
+
get requestLanguage() {
|
|
1326
|
+
return this.language;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* requestRaw performs one call, retrying per the policy, and returns the Response as it
|
|
1330
|
+
* arrived, including a non-ok one, with its body unread.
|
|
1331
|
+
*
|
|
1332
|
+
* It is the single retry loop every other method composes. The Data API needs the raw
|
|
1333
|
+
* response because a GraphQL failure arrives as an envelope under the failure's own HTTP
|
|
1334
|
+
* status, so classifying by status alone would discard the API's message.
|
|
1335
|
+
*
|
|
1336
|
+
* Each attempt waits for the response's headers for the call's own `timeoutMs`, or else the
|
|
1337
|
+
* larger of the client's and the operation's `serverBudgetMs` plus five seconds. A write that
|
|
1338
|
+
* declares `Idempotency-Key` sends one key on every attempt, the caller's or one drawn before
|
|
1339
|
+
* the first, and an operation that declares none sends none. Each attempt reads the credential
|
|
1340
|
+
* again, so a repeat carries the session token the credential holds when it is sent. A response
|
|
1341
|
+
* it repeats has its body cancelled. Every wait between attempts comes out of the call's
|
|
1342
|
+
* `retry.maxWaitMs`, and a wait that does not fit is not taken: the response that asked for it
|
|
1343
|
+
* comes back as it is. A 409 whose key is still in use is repeated within that budget alone,
|
|
1344
|
+
* after at least a second, and not counted against `retry.maxRetries`. Where the runtime has
|
|
1345
|
+
* `AbortSignal.any`, the caller's signal reaches the returned body as well; elsewhere a caller
|
|
1346
|
+
* reading the body itself cancels it through `response.body`. The client's `onResponse` is told
|
|
1347
|
+
* of every attempt an answer came back to.
|
|
1348
|
+
*
|
|
1349
|
+
* @throws `MountayaConfigurationError` before the first attempt, when the call asks for
|
|
1350
|
+
* `text/event-stream`, the credential cannot make it, its `retry`, `timeoutMs` or
|
|
1351
|
+
* `serverBudgetMs` is out of range, its `accept`, `idempotencyKey` or `ifMatch` is one no
|
|
1352
|
+
* request header carries, its body cannot be sent as JSON or holds a web address with no
|
|
1353
|
+
* scheme where the operation's contract types one, or its path leaves the base URL or holds an
|
|
1354
|
+
* empty or a dot segment, and once a wait for a session token ends with none on a call that
|
|
1355
|
+
* requires a session, before a repeat as before the first attempt;
|
|
1356
|
+
* `MountayaConnectionError` when no response was obtained at all, saying whether the attempt
|
|
1357
|
+
* timed out, or when a session token the credential's source reports on its way has not
|
|
1358
|
+
* landed within the call's `timeoutMs`, else the client's; {@link abortReasonOf} the caller's
|
|
1359
|
+
* signal once it aborts, whatever `fetch` rejected with. Every error raised once the call's
|
|
1360
|
+
* own arguments are accepted carries the `idempotencyKey` the call fixed, where it fixed one:
|
|
1361
|
+
* a credential its first attempt refuses and a first token's wait its budget ends included.
|
|
1362
|
+
*/
|
|
1363
|
+
async requestRaw(args) {
|
|
1364
|
+
return (await this.send(args)).response;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* send is {@link requestRaw}, answering the `Idempotency-Key` the call sent beside the response,
|
|
1368
|
+
* where it sent one, so the error its answer is read into carries the key a caller sends the
|
|
1369
|
+
* call again with.
|
|
1370
|
+
*/
|
|
1371
|
+
async send(args) {
|
|
1372
|
+
assertCallerHeader("accept", args.accept, args.operationId);
|
|
1373
|
+
refuseEventStream(args);
|
|
1374
|
+
const timeoutMs = attemptBudget(this.timeoutMs, args);
|
|
1375
|
+
const takesKey = args.takesIdempotencyKey === true;
|
|
1376
|
+
if (takesKey) {
|
|
1377
|
+
assertCallerHeader("idempotencyKey", args.idempotencyKey, args.operationId);
|
|
1378
|
+
}
|
|
1379
|
+
assertCallerHeader("ifMatch", args.ifMatch, args.operationId);
|
|
1380
|
+
const url = buildUrl(this.baseUrls[args.surface], args.path, args.query, args.operationId);
|
|
1381
|
+
const retry = resolveRetry(this.retry, args.retry, args.operationId);
|
|
1382
|
+
const body = encodeBody(args.body, args.operationId);
|
|
1383
|
+
if (args.surface === "rest" && typeof body === "string") {
|
|
1384
|
+
assertWebAddresses(args.operationId, body);
|
|
1385
|
+
}
|
|
1386
|
+
const source = args.takesNoCredential === true || args.requiresSecretKey === true ? void 0 : sessionSourceOf(this.credential);
|
|
1387
|
+
const waitForSession = () => source === void 0 ? void 0 : (
|
|
1388
|
+
// Bounded by the call's own budget, else the client's: the operation's own is the most
|
|
1389
|
+
// the API spends on it, and the mint is the application's endpoint, not the API.
|
|
1390
|
+
waitForSessionToken(source, {
|
|
1391
|
+
operationId: args.operationId,
|
|
1392
|
+
signal: args.signal,
|
|
1393
|
+
timeoutMs: args.timeoutMs === void 0 ? this.timeoutMs : timeoutMs
|
|
1394
|
+
})
|
|
1395
|
+
);
|
|
1396
|
+
const idempotencyKey = takesKey ? args.idempotencyKey ?? mintIdempotencyKey() : void 0;
|
|
1397
|
+
const keyed = idempotencyKey !== void 0;
|
|
1398
|
+
let headers;
|
|
1399
|
+
try {
|
|
1400
|
+
const firstWait = waitForSession();
|
|
1401
|
+
if (firstWait !== void 0) {
|
|
1402
|
+
await firstWait;
|
|
1403
|
+
}
|
|
1404
|
+
headers = this.headers(args, idempotencyKey);
|
|
1405
|
+
} catch (error) {
|
|
1406
|
+
throw carryingKey(error, idempotencyKey);
|
|
1407
|
+
}
|
|
1408
|
+
const credentials = args.takesNoCredential === true ? "omit" : this.credentialsMode;
|
|
1409
|
+
let waitedMs = 0;
|
|
1410
|
+
let retries = 0;
|
|
1411
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
1412
|
+
if (attempt > 0) {
|
|
1413
|
+
try {
|
|
1414
|
+
const waiting = waitForSession();
|
|
1415
|
+
if (waiting !== void 0) {
|
|
1416
|
+
await waiting;
|
|
1417
|
+
}
|
|
1418
|
+
headers = this.headers(args, idempotencyKey);
|
|
1419
|
+
} catch (error) {
|
|
1420
|
+
throw carryingKey(error, idempotencyKey);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
const deadline = attemptSignal(timeoutMs, args.signal);
|
|
1424
|
+
let response;
|
|
1425
|
+
try {
|
|
1426
|
+
response = await this.doFetch(url, {
|
|
1427
|
+
body,
|
|
1428
|
+
credentials,
|
|
1429
|
+
headers,
|
|
1430
|
+
method: args.method,
|
|
1431
|
+
signal: deadline.signal
|
|
1432
|
+
});
|
|
1433
|
+
} catch (cause) {
|
|
1434
|
+
deadline.release();
|
|
1435
|
+
if (args.signal !== void 0 && isAborted(args.signal)) {
|
|
1436
|
+
throw abortReasonOf(args.signal);
|
|
1437
|
+
}
|
|
1438
|
+
const failure = new MountayaConnectionError(
|
|
1439
|
+
deadline.timedOut() ? `${args.operationId}: no response within ${timeoutMs} ms. Raise timeoutMs for a call that is slow to answer, or check the network path to the API.` : `${args.operationId}: the request failed before a response arrived. Check the network, and that baseUrls.${args.surface} names a host that answers.`,
|
|
1440
|
+
cause,
|
|
1441
|
+
idempotencyKey
|
|
1442
|
+
);
|
|
1443
|
+
if (!shouldRetry({
|
|
1444
|
+
idempotent: args.idempotent,
|
|
1445
|
+
keyed,
|
|
1446
|
+
maxRetries: retry.maxRetries,
|
|
1447
|
+
retries
|
|
1448
|
+
})) {
|
|
1449
|
+
throw failure;
|
|
1450
|
+
}
|
|
1451
|
+
const delay2 = jitteredDelay({
|
|
1452
|
+
attempt,
|
|
1453
|
+
baseDelayMs: retry.baseDelayMs,
|
|
1454
|
+
maxDelayMs: retry.maxDelayMs
|
|
1455
|
+
});
|
|
1456
|
+
if (waitedMs + delay2 > retry.maxWaitMs) {
|
|
1457
|
+
throw failure;
|
|
1458
|
+
}
|
|
1459
|
+
waitedMs += delay2;
|
|
1460
|
+
retries += 1;
|
|
1461
|
+
await sleep(delay2, args.signal);
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
deadline.release();
|
|
1465
|
+
this.report(response, args, attempt);
|
|
1466
|
+
if (response.ok) {
|
|
1467
|
+
return { idempotencyKey, response };
|
|
1468
|
+
}
|
|
1469
|
+
let code;
|
|
1470
|
+
if (response.status === 409 && keyed || response.status === 429) {
|
|
1471
|
+
const text = await readFailureText(response, args.signal);
|
|
1472
|
+
code = firstCodeOf(text);
|
|
1473
|
+
response = rereadable(response, text);
|
|
1474
|
+
}
|
|
1475
|
+
const answered = { code, idempotent: args.idempotent, keyed, status: response.status };
|
|
1476
|
+
if (!shouldRetry({ ...answered, maxRetries: retry.maxRetries, retries })) {
|
|
1477
|
+
return { idempotencyKey, response };
|
|
1478
|
+
}
|
|
1479
|
+
const inUse = isKeyInUse(answered);
|
|
1480
|
+
const scheduled = backoffDelay({
|
|
1481
|
+
attempt,
|
|
1482
|
+
baseDelayMs: retry.baseDelayMs,
|
|
1483
|
+
maxDelayMs: retry.maxDelayMs,
|
|
1484
|
+
retryAfterSeconds: parseRetryAfter(response.headers.get("Retry-After"))
|
|
1485
|
+
});
|
|
1486
|
+
const delay = inUse ? Math.max(KEY_IN_USE_MIN_WAIT_MS, scheduled) : scheduled;
|
|
1487
|
+
if (waitedMs + delay > retry.maxWaitMs) {
|
|
1488
|
+
return { idempotencyKey, response };
|
|
1489
|
+
}
|
|
1490
|
+
discardBody(response);
|
|
1491
|
+
waitedMs += delay;
|
|
1492
|
+
if (!inUse) {
|
|
1493
|
+
retries += 1;
|
|
1494
|
+
}
|
|
1495
|
+
await sleep(delay, args.signal);
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* request performs one call and returns the parsed body, with each instant `args.dates` names
|
|
1500
|
+
* decoded to a `Date` and every other string left a string.
|
|
1501
|
+
*
|
|
1502
|
+
* `T` is asserted rather than validated. The generated operation types come from the
|
|
1503
|
+
* same spec the API serves, so a runtime re-validation would spend time proving
|
|
1504
|
+
* something the contract already guarantees, and would reject a response the moment
|
|
1505
|
+
* the API added a field, which is a compatible change.
|
|
1506
|
+
*
|
|
1507
|
+
* @throws what {@link requestRaw} throws; the `MountayaApiError` class a non-2xx status maps
|
|
1508
|
+
* to; the base `MountayaApiError` for a success whose body is not JSON, carrying the answer's
|
|
1509
|
+
* status and request id with the parser's failure as its `cause`;
|
|
1510
|
+
* `MountayaConnectionError` for a body that broke off before it was complete; the caller's
|
|
1511
|
+
* own abort reason while a body, a success's or a failure's, is still arriving. Each error but
|
|
1512
|
+
* the abort reason carries the `idempotencyKey` the call sent, where it sent one.
|
|
1513
|
+
*/
|
|
1514
|
+
async request(args) {
|
|
1515
|
+
const { idempotencyKey, response } = await this.send(args);
|
|
1516
|
+
const call = { ...args, idempotencyKey };
|
|
1517
|
+
if (!response.ok) {
|
|
1518
|
+
throw await readFailure(response, call);
|
|
1519
|
+
}
|
|
1520
|
+
const text = await readText(response, call);
|
|
1521
|
+
const decoded = decodeSuccessDates(
|
|
1522
|
+
parseSuccessBody(text, response, call),
|
|
1523
|
+
args.dates,
|
|
1524
|
+
response,
|
|
1525
|
+
call
|
|
1526
|
+
);
|
|
1527
|
+
return withAbsentNulls(
|
|
1528
|
+
decoded,
|
|
1529
|
+
args.surface === "rest" ? responseNullMask(args.operationId) : void 0
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* requestBinary performs one call and returns the bytes with the two headers that
|
|
1534
|
+
* describe them, for tile and export responses that are protobuf, PNG, WebP or an
|
|
1535
|
+
* octet stream rather than JSON.
|
|
1536
|
+
*
|
|
1537
|
+
* It goes through the same retry loop as every other call, so tile fetches, the surface most
|
|
1538
|
+
* likely to hit a quota at 600 requests per minute across a whole organization, back off like
|
|
1539
|
+
* the rest.
|
|
1540
|
+
*
|
|
1541
|
+
* @throws as {@link request} does, except for a success whose body is not JSON: the bytes are
|
|
1542
|
+
* handed back as they arrived, with the `Content-Type` that says what they are.
|
|
1543
|
+
*/
|
|
1544
|
+
async requestBinary(args) {
|
|
1545
|
+
const { idempotencyKey, response } = await this.send(args);
|
|
1546
|
+
const call = { ...args, idempotencyKey };
|
|
1547
|
+
if (!response.ok) {
|
|
1548
|
+
throw await readFailure(response, call);
|
|
1549
|
+
}
|
|
1550
|
+
return {
|
|
1551
|
+
bytes: await readBytes(response, call),
|
|
1552
|
+
contentType: response.headers.get("Content-Type") ?? void 0,
|
|
1553
|
+
filename: filenameFromContentDisposition(response.headers.get("Content-Disposition"))
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* headers builds the headers of one attempt, and is where every local credential refusal is
|
|
1558
|
+
* raised: {@link credentialHeaders} reads what the operation declares off `args`, which
|
|
1559
|
+
* carries the same members.
|
|
1560
|
+
*
|
|
1561
|
+
* Built for the first attempt before the retry loop, where a refusal leaves nothing sent, and
|
|
1562
|
+
* again for each repeat, so a session token held as a function or a source is read for every
|
|
1563
|
+
* attempt: a repeat carries the token the credential holds as it leaves, never one that expired
|
|
1564
|
+
* during the waits before it. The call's key and its tag ride every attempt alike, and so does
|
|
1565
|
+
* `X-Mountaya-Client`, whatever the credential and whatever the operation declares.
|
|
1566
|
+
*/
|
|
1567
|
+
headers(args, idempotencyKey) {
|
|
1568
|
+
const operation = args;
|
|
1569
|
+
const headers = {
|
|
1570
|
+
Accept: args.accept ?? "application/json",
|
|
1571
|
+
...credentialHeaders(this.credential, operation)
|
|
1572
|
+
};
|
|
1573
|
+
if (args.body !== void 0 && !isFormData(args.body)) {
|
|
1574
|
+
headers["Content-Type"] = "application/json";
|
|
1575
|
+
}
|
|
1576
|
+
headers["Accept-Language"] = this.language ?? NO_LANGUAGE;
|
|
1577
|
+
headers["X-Mountaya-Client"] = CLIENT_HEADER_VALUE;
|
|
1578
|
+
if (idempotencyKey !== void 0) {
|
|
1579
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
1580
|
+
}
|
|
1581
|
+
if (args.ifMatch !== void 0) {
|
|
1582
|
+
headers["If-Match"] = args.ifMatch;
|
|
1583
|
+
}
|
|
1584
|
+
return headers;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* report tells the client's `onResponse` of one answer. A fault the hook throws leaves the call
|
|
1588
|
+
* as it was and reaches the runtime on a microtask.
|
|
1589
|
+
*/
|
|
1590
|
+
report(response, call, attempt) {
|
|
1591
|
+
if (this.onResponse === void 0) {
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
try {
|
|
1595
|
+
this.onResponse({
|
|
1596
|
+
attempt,
|
|
1597
|
+
operationId: call.operationId,
|
|
1598
|
+
replayed: replayedOf(response.headers),
|
|
1599
|
+
status: response.status,
|
|
1600
|
+
surface: call.surface,
|
|
1601
|
+
...answerDetailsOf(response.headers)
|
|
1602
|
+
});
|
|
1603
|
+
} catch (fault) {
|
|
1604
|
+
surfaceFault(fault);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
// src/core/rules/selection.ts
|
|
1610
|
+
var INDENT = " ";
|
|
1611
|
+
var MountayaSelectionError = class extends MountayaError {
|
|
1612
|
+
name = "MountayaSelectionError";
|
|
1613
|
+
};
|
|
1614
|
+
var MAX_MEMOISED_DOCUMENTS = 256;
|
|
1615
|
+
var documents = /* @__PURE__ */ new WeakMap();
|
|
1616
|
+
var selectionKey = (selection, tree) => {
|
|
1617
|
+
const prototype = Object.getPrototypeOf(selection);
|
|
1618
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
1619
|
+
return void 0;
|
|
1620
|
+
}
|
|
1621
|
+
let key = "{";
|
|
1622
|
+
for (const [name, picked] of Object.entries(selection)) {
|
|
1623
|
+
if (picked === void 0) {
|
|
1624
|
+
continue;
|
|
1625
|
+
}
|
|
1626
|
+
const node = Object.hasOwn(tree, name) ? tree[name] : void 0;
|
|
1627
|
+
if (node === void 0) {
|
|
1628
|
+
return void 0;
|
|
1629
|
+
}
|
|
1630
|
+
if (picked === true) {
|
|
1631
|
+
key += `${JSON.stringify(name)}:true,`;
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
if (node === true || typeof picked !== "object" || picked === null) {
|
|
1635
|
+
return void 0;
|
|
1636
|
+
}
|
|
1637
|
+
const nested = selectionKey(picked, node);
|
|
1638
|
+
if (nested === void 0) {
|
|
1639
|
+
return void 0;
|
|
1640
|
+
}
|
|
1641
|
+
key += `${JSON.stringify(name)}:${nested},`;
|
|
1642
|
+
}
|
|
1643
|
+
return `${key}}`;
|
|
1644
|
+
};
|
|
1645
|
+
var documentFor = (operation, inputType, tree, fullDocument, selection) => {
|
|
1646
|
+
if (selection === void 0) {
|
|
1647
|
+
return fullDocument;
|
|
1648
|
+
}
|
|
1649
|
+
if (typeof selection !== "object" || selection === null) {
|
|
1650
|
+
return printDocument(operation, inputType, tree, selection);
|
|
1651
|
+
}
|
|
1652
|
+
const content = selectionKey(selection, tree);
|
|
1653
|
+
if (content === void 0) {
|
|
1654
|
+
return printDocument(operation, inputType, tree, selection);
|
|
1655
|
+
}
|
|
1656
|
+
const key = `${operation}\0${inputType}\0${content}`;
|
|
1657
|
+
const memo = documents.get(tree) ?? /* @__PURE__ */ new Map();
|
|
1658
|
+
const memoised = memo.get(key);
|
|
1659
|
+
if (memoised !== void 0) {
|
|
1660
|
+
return memoised;
|
|
1661
|
+
}
|
|
1662
|
+
const document = printDocument(operation, inputType, tree, selection);
|
|
1663
|
+
if (memo.size >= MAX_MEMOISED_DOCUMENTS) {
|
|
1664
|
+
const oldest = memo.keys().next().value;
|
|
1665
|
+
if (oldest !== void 0) {
|
|
1666
|
+
memo.delete(oldest);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
memo.set(key, document);
|
|
1670
|
+
documents.set(tree, memo);
|
|
1671
|
+
return document;
|
|
1672
|
+
};
|
|
1673
|
+
var printDocument = (operation, inputType, tree, selection) => {
|
|
1674
|
+
const body = printSelection(operation, tree, selection, 1);
|
|
1675
|
+
if (body === "") {
|
|
1676
|
+
throw new MountayaSelectionError(`${operation}: a selection must name at least one field`);
|
|
1677
|
+
}
|
|
1678
|
+
return `query ${exportName(operation)}($input: ${inputType}) {
|
|
1679
|
+
${INDENT}${operation}(input: $input) {
|
|
1680
|
+
${body}${INDENT}}
|
|
1681
|
+
}
|
|
1682
|
+
`;
|
|
1683
|
+
};
|
|
1684
|
+
var printSelection = (at, tree, selection, depth) => {
|
|
1685
|
+
if (selection !== void 0) {
|
|
1686
|
+
assertSelectable(at, tree, selection);
|
|
1687
|
+
}
|
|
1688
|
+
const indent = INDENT.repeat(depth + 1);
|
|
1689
|
+
let out = "";
|
|
1690
|
+
for (const [name, node] of Object.entries(tree)) {
|
|
1691
|
+
const picked = selection === void 0 ? true : selection[name];
|
|
1692
|
+
if (picked === void 0) {
|
|
1693
|
+
continue;
|
|
1694
|
+
}
|
|
1695
|
+
if (node === true) {
|
|
1696
|
+
out += `${indent}${name}
|
|
1697
|
+
`;
|
|
1698
|
+
continue;
|
|
1699
|
+
}
|
|
1700
|
+
const sub = printSelection(
|
|
1701
|
+
`${at}.${name}`,
|
|
1702
|
+
node,
|
|
1703
|
+
picked === true ? void 0 : picked,
|
|
1704
|
+
depth + 1
|
|
1705
|
+
);
|
|
1706
|
+
if (sub === "") {
|
|
1707
|
+
throw new MountayaSelectionError(`${at}.${name}: a selection must name at least one field`);
|
|
1708
|
+
}
|
|
1709
|
+
out += `${indent}${name} {
|
|
1710
|
+
${sub}${indent}}
|
|
1711
|
+
`;
|
|
1712
|
+
}
|
|
1713
|
+
return out;
|
|
1714
|
+
};
|
|
1715
|
+
var isSelectionValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1716
|
+
var spell = (value) => {
|
|
1717
|
+
if (typeof value === "string") {
|
|
1718
|
+
return JSON.stringify(value);
|
|
1719
|
+
}
|
|
1720
|
+
return typeof value === "object" || typeof value === "function" ? describeType(value) : String(value);
|
|
1721
|
+
};
|
|
1722
|
+
function assertSelectable(at, tree, selection) {
|
|
1723
|
+
if (!isSelectionValue(selection)) {
|
|
1724
|
+
throw new MountayaSelectionError(
|
|
1725
|
+
`${at}: a selection is an object naming fields, and this one is ${spell(selection)}; valid fields are: ${Object.keys(tree).join(", ")}`
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
for (const [name, picked] of Object.entries(selection)) {
|
|
1729
|
+
if (picked === void 0) {
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
const node = Object.hasOwn(tree, name) ? tree[name] : void 0;
|
|
1733
|
+
if (node === void 0) {
|
|
1734
|
+
throw new MountayaSelectionError(
|
|
1735
|
+
`${at}: unknown field "${name}"; valid fields are: ${Object.keys(tree).join(", ")}`
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
if (picked !== true && !isSelectionValue(picked)) {
|
|
1739
|
+
throw new MountayaSelectionError(
|
|
1740
|
+
`${at}.${name} is ${spell(picked)}; select a field with true, or leave it out.`
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1743
|
+
if (node === true && picked !== true) {
|
|
1744
|
+
throw new MountayaSelectionError(
|
|
1745
|
+
`${at}: field "${name}" is a leaf and takes no sub-selection`
|
|
1746
|
+
);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
var exportName = (name) => name === "" ? name : `${name[0]?.toUpperCase() ?? ""}${name.slice(1)}`;
|
|
1751
|
+
|
|
1752
|
+
// src/data/selection.gen.ts
|
|
1753
|
+
var selection_gen_exports = {};
|
|
1754
|
+
__export(selection_gen_exports, {
|
|
1755
|
+
analyzeGeometryFields: () => analyzeGeometryFields,
|
|
1756
|
+
directionsFields: () => directionsFields,
|
|
1757
|
+
exportItineraryFields: () => exportItineraryFields,
|
|
1758
|
+
geocodeFields: () => geocodeFields,
|
|
1759
|
+
isochronesFields: () => isochronesFields,
|
|
1760
|
+
itineraryFields: () => itineraryFields,
|
|
1761
|
+
matrixFields: () => matrixFields,
|
|
1762
|
+
poisFields: () => poisFields,
|
|
1763
|
+
reverseGeocodeFields: () => reverseGeocodeFields,
|
|
1764
|
+
searchFields: () => searchFields,
|
|
1765
|
+
suggestionsFields: () => suggestionsFields,
|
|
1766
|
+
terrainGridFields: () => terrainGridFields,
|
|
1767
|
+
terrainProfileFields: () => terrainProfileFields,
|
|
1768
|
+
terrainSamplesFields: () => terrainSamplesFields
|
|
1769
|
+
});
|
|
1770
|
+
var analyzeGeometryFields = {
|
|
1771
|
+
analysis: {
|
|
1772
|
+
elevation: {
|
|
1773
|
+
altitude: { max: true, min: true },
|
|
1774
|
+
ascent: true,
|
|
1775
|
+
descent: true,
|
|
1776
|
+
gradient: { max: true, min: true }
|
|
1777
|
+
},
|
|
1778
|
+
elevations: true,
|
|
1779
|
+
slopeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1780
|
+
speedInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1781
|
+
surfaceInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1782
|
+
trailDifficultyInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1783
|
+
wayTypeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1784
|
+
advisories: {
|
|
1785
|
+
tollway: true,
|
|
1786
|
+
restrictedAccess: true,
|
|
1787
|
+
tollwayInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1788
|
+
roadAccessInfo: { fromIndex: true, toIndex: true, values: true }
|
|
1789
|
+
}
|
|
1790
|
+
},
|
|
1791
|
+
duration: true
|
|
1792
|
+
};
|
|
1793
|
+
var directionsFields = {
|
|
1794
|
+
routes: {
|
|
1795
|
+
distance: true,
|
|
1796
|
+
duration: true,
|
|
1797
|
+
elevation: {
|
|
1798
|
+
altitude: { max: true, min: true },
|
|
1799
|
+
ascent: true,
|
|
1800
|
+
descent: true,
|
|
1801
|
+
gradient: { max: true, min: true }
|
|
1802
|
+
},
|
|
1803
|
+
geometry: true,
|
|
1804
|
+
analysis: {
|
|
1805
|
+
elevation: {
|
|
1806
|
+
altitude: { max: true, min: true },
|
|
1807
|
+
ascent: true,
|
|
1808
|
+
descent: true,
|
|
1809
|
+
gradient: { max: true, min: true }
|
|
1810
|
+
},
|
|
1811
|
+
elevations: true,
|
|
1812
|
+
slopeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1813
|
+
speedInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1814
|
+
surfaceInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1815
|
+
trailDifficultyInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1816
|
+
wayTypeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1817
|
+
advisories: {
|
|
1818
|
+
tollway: true,
|
|
1819
|
+
restrictedAccess: true,
|
|
1820
|
+
tollwayInfo: { fromIndex: true, toIndex: true, value: true },
|
|
1821
|
+
roadAccessInfo: { fromIndex: true, toIndex: true, values: true }
|
|
1822
|
+
}
|
|
1823
|
+
},
|
|
1824
|
+
avoidance: true,
|
|
1825
|
+
summary: true,
|
|
1826
|
+
steps: {
|
|
1827
|
+
fromIndex: true,
|
|
1828
|
+
toIndex: true,
|
|
1829
|
+
type: true,
|
|
1830
|
+
name: true,
|
|
1831
|
+
distance: true,
|
|
1832
|
+
duration: true,
|
|
1833
|
+
exitNumber: true
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
var exportItineraryFields = {
|
|
1838
|
+
url: true,
|
|
1839
|
+
filename: true,
|
|
1840
|
+
format: true,
|
|
1841
|
+
expiresAt: true
|
|
1842
|
+
};
|
|
1843
|
+
var geocodeFields = {
|
|
1844
|
+
count: true,
|
|
1845
|
+
places: {
|
|
1846
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
1847
|
+
name: true,
|
|
1848
|
+
label: true,
|
|
1849
|
+
layer: true,
|
|
1850
|
+
category: true,
|
|
1851
|
+
point: true,
|
|
1852
|
+
bounds: true,
|
|
1853
|
+
country: true,
|
|
1854
|
+
countryName: true,
|
|
1855
|
+
region: true,
|
|
1856
|
+
county: true,
|
|
1857
|
+
city: true,
|
|
1858
|
+
postcode: true,
|
|
1859
|
+
street: true,
|
|
1860
|
+
houseNumber: true
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
var isochronesFields = {
|
|
1864
|
+
isochrones: { value: true, area: true, reachFactor: true, center: true, geometry: true }
|
|
1865
|
+
};
|
|
1866
|
+
var itineraryFields = {
|
|
1867
|
+
id: true,
|
|
1868
|
+
name: true,
|
|
1869
|
+
description: true,
|
|
1870
|
+
activitySlug: true,
|
|
1871
|
+
distance: true,
|
|
1872
|
+
ascent: true,
|
|
1873
|
+
isPrivate: true,
|
|
1874
|
+
organizationId: true,
|
|
1875
|
+
segments: {
|
|
1876
|
+
id: true,
|
|
1877
|
+
name: true,
|
|
1878
|
+
description: true,
|
|
1879
|
+
position: true,
|
|
1880
|
+
groupId: true,
|
|
1881
|
+
distance: true,
|
|
1882
|
+
duration: true,
|
|
1883
|
+
ascent: true,
|
|
1884
|
+
descent: true,
|
|
1885
|
+
altitude: { max: true, min: true },
|
|
1886
|
+
gradient: { max: true, min: true },
|
|
1887
|
+
geometry: true
|
|
1888
|
+
},
|
|
1889
|
+
waypoints: {
|
|
1890
|
+
id: true,
|
|
1891
|
+
name: true,
|
|
1892
|
+
description: true,
|
|
1893
|
+
position: true,
|
|
1894
|
+
point: true,
|
|
1895
|
+
amenities: true,
|
|
1896
|
+
timing: { cutoffAt: true, stopDuration: true },
|
|
1897
|
+
contact: {
|
|
1898
|
+
website: true,
|
|
1899
|
+
phone: true,
|
|
1900
|
+
email: true,
|
|
1901
|
+
address: true,
|
|
1902
|
+
openingHours: true,
|
|
1903
|
+
bookingUrl: true
|
|
1904
|
+
},
|
|
1905
|
+
media: { photos: { url: true, caption: true }, links: { label: true, url: true } },
|
|
1906
|
+
properties: { key: true, label: true, value: true, format: true }
|
|
1907
|
+
},
|
|
1908
|
+
groups: { id: true, name: true, color: true, speed: true },
|
|
1909
|
+
segmentCount: true,
|
|
1910
|
+
waypointCount: true,
|
|
1911
|
+
groupCount: true
|
|
1912
|
+
};
|
|
1913
|
+
var matrixFields = { durations: true, distances: true };
|
|
1914
|
+
var poisFields = {
|
|
1915
|
+
count: true,
|
|
1916
|
+
pois: {
|
|
1917
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
1918
|
+
name: true,
|
|
1919
|
+
category: true,
|
|
1920
|
+
point: true,
|
|
1921
|
+
elevation: true,
|
|
1922
|
+
tags: { key: true, value: true },
|
|
1923
|
+
distanceMeters: true,
|
|
1924
|
+
country: true,
|
|
1925
|
+
countryName: true,
|
|
1926
|
+
region: true,
|
|
1927
|
+
city: true
|
|
1928
|
+
}
|
|
1929
|
+
};
|
|
1930
|
+
var reverseGeocodeFields = {
|
|
1931
|
+
point: true,
|
|
1932
|
+
places: {
|
|
1933
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
1934
|
+
name: true,
|
|
1935
|
+
label: true,
|
|
1936
|
+
layer: true,
|
|
1937
|
+
category: true,
|
|
1938
|
+
point: true,
|
|
1939
|
+
bounds: true,
|
|
1940
|
+
country: true,
|
|
1941
|
+
countryName: true,
|
|
1942
|
+
region: true,
|
|
1943
|
+
county: true,
|
|
1944
|
+
city: true,
|
|
1945
|
+
postcode: true,
|
|
1946
|
+
street: true,
|
|
1947
|
+
houseNumber: true
|
|
1948
|
+
},
|
|
1949
|
+
count: true
|
|
1950
|
+
};
|
|
1951
|
+
var searchFields = {
|
|
1952
|
+
query: true,
|
|
1953
|
+
language: true,
|
|
1954
|
+
targets: {
|
|
1955
|
+
places: true,
|
|
1956
|
+
pois: true,
|
|
1957
|
+
ways: true,
|
|
1958
|
+
itineraries: true,
|
|
1959
|
+
collections: true,
|
|
1960
|
+
zones: true
|
|
1961
|
+
},
|
|
1962
|
+
places: {
|
|
1963
|
+
count: true,
|
|
1964
|
+
places: {
|
|
1965
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
1966
|
+
name: true,
|
|
1967
|
+
label: true,
|
|
1968
|
+
layer: true,
|
|
1969
|
+
category: true,
|
|
1970
|
+
point: true,
|
|
1971
|
+
bounds: true,
|
|
1972
|
+
country: true,
|
|
1973
|
+
countryName: true,
|
|
1974
|
+
region: true,
|
|
1975
|
+
county: true,
|
|
1976
|
+
city: true,
|
|
1977
|
+
postcode: true,
|
|
1978
|
+
street: true,
|
|
1979
|
+
houseNumber: true
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
pois: {
|
|
1983
|
+
count: true,
|
|
1984
|
+
pois: {
|
|
1985
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
1986
|
+
name: true,
|
|
1987
|
+
category: true,
|
|
1988
|
+
point: true,
|
|
1989
|
+
elevation: true,
|
|
1990
|
+
tags: { key: true, value: true },
|
|
1991
|
+
distanceMeters: true,
|
|
1992
|
+
country: true,
|
|
1993
|
+
countryName: true,
|
|
1994
|
+
region: true,
|
|
1995
|
+
city: true
|
|
1996
|
+
}
|
|
1997
|
+
},
|
|
1998
|
+
ways: {
|
|
1999
|
+
count: true,
|
|
2000
|
+
ways: {
|
|
2001
|
+
osm: { id: true, type: true, key: true, value: true },
|
|
2002
|
+
name: true,
|
|
2003
|
+
highway: true,
|
|
2004
|
+
surface: true,
|
|
2005
|
+
sacScale: true,
|
|
2006
|
+
point: true,
|
|
2007
|
+
bounds: true,
|
|
2008
|
+
coordinates: true,
|
|
2009
|
+
activityCompatible: true,
|
|
2010
|
+
country: true,
|
|
2011
|
+
countryName: true,
|
|
2012
|
+
region: true,
|
|
2013
|
+
city: true
|
|
2014
|
+
},
|
|
2015
|
+
activityApplied: true
|
|
2016
|
+
},
|
|
2017
|
+
itineraries: {
|
|
2018
|
+
count: true,
|
|
2019
|
+
itineraries: {
|
|
2020
|
+
id: true,
|
|
2021
|
+
name: true,
|
|
2022
|
+
description: true,
|
|
2023
|
+
distance: true,
|
|
2024
|
+
ascent: true,
|
|
2025
|
+
activitySlug: true,
|
|
2026
|
+
start: true,
|
|
2027
|
+
bounds: true,
|
|
2028
|
+
isPrivate: true,
|
|
2029
|
+
organizationId: true,
|
|
2030
|
+
score: true,
|
|
2031
|
+
matchedField: true
|
|
2032
|
+
}
|
|
2033
|
+
},
|
|
2034
|
+
collections: {
|
|
2035
|
+
count: true,
|
|
2036
|
+
collections: {
|
|
2037
|
+
id: true,
|
|
2038
|
+
name: true,
|
|
2039
|
+
description: true,
|
|
2040
|
+
count: { itineraries: true, zones: true },
|
|
2041
|
+
bounds: true,
|
|
2042
|
+
isPrivate: true,
|
|
2043
|
+
organizationId: true,
|
|
2044
|
+
score: true,
|
|
2045
|
+
matchedField: true
|
|
2046
|
+
}
|
|
2047
|
+
},
|
|
2048
|
+
zones: {
|
|
2049
|
+
count: true,
|
|
2050
|
+
zones: {
|
|
2051
|
+
id: true,
|
|
2052
|
+
name: true,
|
|
2053
|
+
description: true,
|
|
2054
|
+
level: true,
|
|
2055
|
+
mode: true,
|
|
2056
|
+
point: true,
|
|
2057
|
+
bounds: true,
|
|
2058
|
+
isPrivate: true,
|
|
2059
|
+
organizationId: true,
|
|
2060
|
+
score: true,
|
|
2061
|
+
matchedField: true
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
errors: { target: true, code: true, message: true }
|
|
2065
|
+
};
|
|
2066
|
+
var suggestionsFields = {
|
|
2067
|
+
routes: {
|
|
2068
|
+
distance: true,
|
|
2069
|
+
duration: true,
|
|
2070
|
+
elevation: {
|
|
2071
|
+
altitude: { max: true, min: true },
|
|
2072
|
+
ascent: true,
|
|
2073
|
+
descent: true,
|
|
2074
|
+
gradient: { max: true, min: true }
|
|
2075
|
+
},
|
|
2076
|
+
geometry: true,
|
|
2077
|
+
analysis: {
|
|
2078
|
+
elevation: {
|
|
2079
|
+
altitude: { max: true, min: true },
|
|
2080
|
+
ascent: true,
|
|
2081
|
+
descent: true,
|
|
2082
|
+
gradient: { max: true, min: true }
|
|
2083
|
+
},
|
|
2084
|
+
elevations: true,
|
|
2085
|
+
slopeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2086
|
+
speedInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2087
|
+
surfaceInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2088
|
+
trailDifficultyInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2089
|
+
wayTypeInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2090
|
+
advisories: {
|
|
2091
|
+
tollway: true,
|
|
2092
|
+
restrictedAccess: true,
|
|
2093
|
+
tollwayInfo: { fromIndex: true, toIndex: true, value: true },
|
|
2094
|
+
roadAccessInfo: { fromIndex: true, toIndex: true, values: true }
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
summary: true,
|
|
2098
|
+
steps: {
|
|
2099
|
+
fromIndex: true,
|
|
2100
|
+
toIndex: true,
|
|
2101
|
+
type: true,
|
|
2102
|
+
name: true,
|
|
2103
|
+
distance: true,
|
|
2104
|
+
duration: true,
|
|
2105
|
+
exitNumber: true
|
|
2106
|
+
},
|
|
2107
|
+
seed: true
|
|
2108
|
+
}
|
|
2109
|
+
};
|
|
2110
|
+
var terrainGridFields = {
|
|
2111
|
+
count: true,
|
|
2112
|
+
coveredCount: true,
|
|
2113
|
+
zoom: true,
|
|
2114
|
+
resolutionMeters: true,
|
|
2115
|
+
cols: true,
|
|
2116
|
+
rows: true,
|
|
2117
|
+
cells: {
|
|
2118
|
+
point: true,
|
|
2119
|
+
elevation: true,
|
|
2120
|
+
slope: true,
|
|
2121
|
+
aspect: true,
|
|
2122
|
+
aspectOctant: true,
|
|
2123
|
+
steepnessBand: true,
|
|
2124
|
+
distanceMeters: true
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
var terrainProfileFields = {
|
|
2128
|
+
count: true,
|
|
2129
|
+
coveredCount: true,
|
|
2130
|
+
zoom: true,
|
|
2131
|
+
resolutionMeters: true,
|
|
2132
|
+
samples: {
|
|
2133
|
+
point: true,
|
|
2134
|
+
elevation: true,
|
|
2135
|
+
slope: true,
|
|
2136
|
+
aspect: true,
|
|
2137
|
+
aspectOctant: true,
|
|
2138
|
+
steepnessBand: true,
|
|
2139
|
+
distanceMeters: true
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
2142
|
+
var terrainSamplesFields = {
|
|
2143
|
+
count: true,
|
|
2144
|
+
coveredCount: true,
|
|
2145
|
+
zoom: true,
|
|
2146
|
+
resolutionMeters: true,
|
|
2147
|
+
samples: {
|
|
2148
|
+
point: true,
|
|
2149
|
+
elevation: true,
|
|
2150
|
+
slope: true,
|
|
2151
|
+
aspect: true,
|
|
2152
|
+
aspectOctant: true,
|
|
2153
|
+
steepnessBand: true,
|
|
2154
|
+
distanceMeters: true
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
|
|
2158
|
+
// src/data/operations.gen.ts
|
|
2159
|
+
var operations_gen_exports = {};
|
|
2160
|
+
__export(operations_gen_exports, {
|
|
2161
|
+
analyzeGeometry: () => analyzeGeometry,
|
|
2162
|
+
bind: () => bind,
|
|
2163
|
+
directions: () => directions,
|
|
2164
|
+
exportItinerary: () => exportItinerary,
|
|
2165
|
+
geocode: () => geocode,
|
|
2166
|
+
isochrones: () => isochrones,
|
|
2167
|
+
itinerary: () => itinerary,
|
|
2168
|
+
matrix: () => matrix,
|
|
2169
|
+
pois: () => pois,
|
|
2170
|
+
reverseGeocode: () => reverseGeocode,
|
|
2171
|
+
search: () => search,
|
|
2172
|
+
suggestions: () => suggestions,
|
|
2173
|
+
terrainGrid: () => terrainGrid,
|
|
2174
|
+
terrainProfile: () => terrainProfile,
|
|
2175
|
+
terrainSamples: () => terrainSamples
|
|
2176
|
+
});
|
|
2177
|
+
|
|
2178
|
+
// src/core/rules/graphql.ts
|
|
2179
|
+
var DATA_API_BUDGET_MS = 3e4;
|
|
2180
|
+
var apqUnsupported = /* @__PURE__ */ new WeakSet();
|
|
2181
|
+
var MAX_MEMOISED_DIGESTS = 256;
|
|
2182
|
+
var documentHashes = /* @__PURE__ */ new Map();
|
|
2183
|
+
var subtleCrypto = () => {
|
|
2184
|
+
const runtime = globalThis;
|
|
2185
|
+
return runtime.crypto?.subtle;
|
|
2186
|
+
};
|
|
2187
|
+
var hashDocument = (query) => {
|
|
2188
|
+
const memoised = documentHashes.get(query);
|
|
2189
|
+
if (memoised !== void 0) {
|
|
2190
|
+
return memoised;
|
|
2191
|
+
}
|
|
2192
|
+
const subtle = subtleCrypto();
|
|
2193
|
+
if (subtle === void 0) {
|
|
2194
|
+
return void 0;
|
|
2195
|
+
}
|
|
2196
|
+
const digest = subtle.digest("SHA-256", new TextEncoder().encode(query)).then(
|
|
2197
|
+
(bytes) => Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("")
|
|
2198
|
+
);
|
|
2199
|
+
digest.catch(() => documentHashes.delete(query));
|
|
2200
|
+
if (documentHashes.size >= MAX_MEMOISED_DIGESTS) {
|
|
2201
|
+
const oldest = documentHashes.keys().next().value;
|
|
2202
|
+
if (oldest !== void 0) {
|
|
2203
|
+
documentHashes.delete(oldest);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
documentHashes.set(query, digest);
|
|
2207
|
+
return digest;
|
|
2208
|
+
};
|
|
2209
|
+
var persistedQueryFor = async (transport, query) => {
|
|
2210
|
+
if (apqUnsupported.has(transport)) {
|
|
2211
|
+
return void 0;
|
|
2212
|
+
}
|
|
2213
|
+
const digest = hashDocument(query);
|
|
2214
|
+
if (digest === void 0) {
|
|
2215
|
+
return void 0;
|
|
2216
|
+
}
|
|
2217
|
+
try {
|
|
2218
|
+
return { sha256Hash: await digest, version: 1 };
|
|
2219
|
+
} catch {
|
|
2220
|
+
return void 0;
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
var named = (entries, message) => entries.some((entry) => entry.message === message);
|
|
2224
|
+
var coded = (entries, code) => entries.some((entry) => entry.extensions?.code === code);
|
|
2225
|
+
var codedAndNamed = (entries, code, message) => entries.some((entry) => entry.extensions?.code === code && entry.message === message);
|
|
2226
|
+
var declinesProtocol = (entries) => named(entries, "PersistedQueryNotSupported") || coded(entries, "PERSISTED_QUERY_NOT_SUPPORTED");
|
|
2227
|
+
var apqRefusal = (entries) => {
|
|
2228
|
+
if (declinesProtocol(entries) || codedAndNamed(entries, "GRAPHQL_VALIDATION_FAILED", "no operation provided")) {
|
|
2229
|
+
return "unsupported";
|
|
2230
|
+
}
|
|
2231
|
+
if (named(entries, "PersistedQueryNotFound") || coded(entries, "PERSISTED_QUERY_NOT_FOUND")) {
|
|
2232
|
+
return "register";
|
|
2233
|
+
}
|
|
2234
|
+
return void 0;
|
|
2235
|
+
};
|
|
2236
|
+
var execute = async (transport, operationId, body, options) => {
|
|
2237
|
+
const response = await transport.requestRaw({
|
|
2238
|
+
body,
|
|
2239
|
+
// Every Data API operation is a query. The POST is GraphQL's transport, not a
|
|
2240
|
+
// mutation, so these are safe to retry, and they are the operations that most need
|
|
2241
|
+
// it, on the surface with the tightest per-minute limit.
|
|
2242
|
+
idempotent: true,
|
|
2243
|
+
method: "POST",
|
|
2244
|
+
operationId,
|
|
2245
|
+
path: "/graphql",
|
|
2246
|
+
// The same fact, told to the credential rules that read it: a refusal names a read as a read,
|
|
2247
|
+
// not as a write. This is the ONE place the method implies the wrong answer, which is why the
|
|
2248
|
+
// flag is declared here and nowhere else.
|
|
2249
|
+
read: true,
|
|
2250
|
+
// The Data API requires a session token beside the publishable key on every request, and
|
|
2251
|
+
// answers one without it with a 401. The SDL has no `security` to generate this from, so
|
|
2252
|
+
// it is stated here, once, for every operation: the declaration a REST operation's
|
|
2253
|
+
// `security` produces, read by the same refusal. No operation here accepts a share token,
|
|
2254
|
+
// which the absence of `acceptsShareToken` says.
|
|
2255
|
+
requiresSession: true,
|
|
2256
|
+
retry: options?.retry,
|
|
2257
|
+
// The Data API states one budget for every operation rather than one per operation, so it
|
|
2258
|
+
// is stated here, once, as a REST operation's `x-timeout-ms` is stated on its descriptor.
|
|
2259
|
+
serverBudgetMs: DATA_API_BUDGET_MS,
|
|
2260
|
+
signal: options?.signal,
|
|
2261
|
+
surface: "data",
|
|
2262
|
+
timeoutMs: options?.timeoutMs
|
|
2263
|
+
});
|
|
2264
|
+
const raw = response.ok ? await readText(response, {
|
|
2265
|
+
idempotent: true,
|
|
2266
|
+
operationId,
|
|
2267
|
+
signal: options?.signal
|
|
2268
|
+
}) : await readFailureText(response, options?.signal);
|
|
2269
|
+
const envelope = (() => {
|
|
2270
|
+
if (response.ok) {
|
|
2271
|
+
return parseSuccessBody(raw, response, { operationId, surface: "data" });
|
|
2272
|
+
}
|
|
2273
|
+
try {
|
|
2274
|
+
return parseJsonWithDates(raw);
|
|
2275
|
+
} catch {
|
|
2276
|
+
return void 0;
|
|
2277
|
+
}
|
|
2278
|
+
})();
|
|
2279
|
+
return { entries: entriesOf(envelope), envelope, raw, response };
|
|
2280
|
+
};
|
|
2281
|
+
var unwrap = async (operationId, attempt, dates) => {
|
|
2282
|
+
const { entries, envelope, raw, response } = attempt;
|
|
2283
|
+
const details = answerDetailsOf(response.headers);
|
|
2284
|
+
if (!response.ok) {
|
|
2285
|
+
if (entries.length > 0) {
|
|
2286
|
+
const retryAfterSeconds = parseRetryAfter(response.headers.get("Retry-After"));
|
|
2287
|
+
throw errorForStatus(
|
|
2288
|
+
failureMessage(operationId, response.status, entries, {
|
|
2289
|
+
rateLimit: details.rateLimit,
|
|
2290
|
+
requestId: details.requestId,
|
|
2291
|
+
retryAfterSeconds
|
|
2292
|
+
}),
|
|
2293
|
+
response.status,
|
|
2294
|
+
entries,
|
|
2295
|
+
{ ...details, metadata: metadataOf(envelope), retryAfter: retryAfterSeconds }
|
|
2296
|
+
);
|
|
2297
|
+
}
|
|
2298
|
+
throw errorFromBody(raw, response, operationId);
|
|
2299
|
+
}
|
|
2300
|
+
if (statesErrors(envelope)) {
|
|
2301
|
+
const message = failureMessage(operationId, void 0, entries);
|
|
2302
|
+
const summary = message === operationId ? `${operationId}: the Data API returned an error` : message;
|
|
2303
|
+
throw new MountayaDataError(
|
|
2304
|
+
details.requestId === void 0 ? summary : `${summary} (request ${details.requestId})`,
|
|
2305
|
+
200,
|
|
2306
|
+
entries,
|
|
2307
|
+
{ ...details, metadata: metadataOf(envelope) }
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
const data = envelope?.data;
|
|
2311
|
+
if (data === void 0 || data === null) {
|
|
2312
|
+
throw new MountayaDataError(`${operationId}: the Data API returned no data`, 200, [], details);
|
|
2313
|
+
}
|
|
2314
|
+
const result = data[operationId];
|
|
2315
|
+
if (result === void 0) {
|
|
2316
|
+
throw new MountayaDataError(
|
|
2317
|
+
`${operationId}: the Data API answered without a '${operationId}' field`,
|
|
2318
|
+
200,
|
|
2319
|
+
[],
|
|
2320
|
+
details
|
|
2321
|
+
);
|
|
2322
|
+
}
|
|
2323
|
+
return decodeSuccessDates(result, dates, response, { operationId });
|
|
2324
|
+
};
|
|
2325
|
+
var runOperation = async (transport, operationId, query, input, options, dates) => {
|
|
2326
|
+
const variables = { input };
|
|
2327
|
+
const persistedQuery = await persistedQueryFor(transport, query);
|
|
2328
|
+
if (persistedQuery === void 0) {
|
|
2329
|
+
const attempt = await execute(transport, operationId, { query, variables }, options);
|
|
2330
|
+
return unwrap(operationId, attempt, dates);
|
|
2331
|
+
}
|
|
2332
|
+
const probe = await execute(
|
|
2333
|
+
transport,
|
|
2334
|
+
operationId,
|
|
2335
|
+
{ extensions: { persistedQuery }, variables },
|
|
2336
|
+
options
|
|
2337
|
+
);
|
|
2338
|
+
const refusal = apqRefusal(probe.entries);
|
|
2339
|
+
if (refusal === void 0) {
|
|
2340
|
+
return unwrap(operationId, probe, dates);
|
|
2341
|
+
}
|
|
2342
|
+
if (refusal === "unsupported") {
|
|
2343
|
+
apqUnsupported.add(transport);
|
|
2344
|
+
}
|
|
2345
|
+
const registration = await execute(
|
|
2346
|
+
transport,
|
|
2347
|
+
operationId,
|
|
2348
|
+
refusal === "register" ? { extensions: { persistedQuery }, query, variables } : { query, variables },
|
|
2349
|
+
options
|
|
2350
|
+
);
|
|
2351
|
+
if (refusal === "register" && declinesProtocol(registration.entries)) {
|
|
2352
|
+
apqUnsupported.add(transport);
|
|
2353
|
+
return unwrap(
|
|
2354
|
+
operationId,
|
|
2355
|
+
await execute(transport, operationId, { query, variables }, options),
|
|
2356
|
+
dates
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
return unwrap(operationId, registration, dates);
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
// src/data/operations.gen.ts
|
|
2363
|
+
var analyzeGeometry = (transport, input, options) => runOperation(
|
|
2364
|
+
transport,
|
|
2365
|
+
"analyzeGeometry",
|
|
2366
|
+
documentFor(
|
|
2367
|
+
"analyzeGeometry",
|
|
2368
|
+
"AnalyzeGeometryInput!",
|
|
2369
|
+
analyzeGeometryFields,
|
|
2370
|
+
"query AnalyzeGeometry($input: AnalyzeGeometryInput!) {\n analyzeGeometry(input: $input) {\n analysis {\n elevation {\n altitude {\n max\n min\n }\n ascent\n descent\n gradient {\n max\n min\n }\n }\n elevations\n slopeInfo {\n fromIndex\n toIndex\n value\n }\n speedInfo {\n fromIndex\n toIndex\n value\n }\n surfaceInfo {\n fromIndex\n toIndex\n value\n }\n trailDifficultyInfo {\n fromIndex\n toIndex\n value\n }\n wayTypeInfo {\n fromIndex\n toIndex\n value\n }\n advisories {\n tollway\n restrictedAccess\n tollwayInfo {\n fromIndex\n toIndex\n value\n }\n roadAccessInfo {\n fromIndex\n toIndex\n values\n }\n }\n }\n duration\n }\n}\n",
|
|
2371
|
+
options?.select
|
|
2372
|
+
),
|
|
2373
|
+
input,
|
|
2374
|
+
options
|
|
2375
|
+
);
|
|
2376
|
+
var directions = (transport, input, options) => runOperation(
|
|
2377
|
+
transport,
|
|
2378
|
+
"directions",
|
|
2379
|
+
documentFor(
|
|
2380
|
+
"directions",
|
|
2381
|
+
"DirectionsInput!",
|
|
2382
|
+
directionsFields,
|
|
2383
|
+
"query Directions($input: DirectionsInput!) {\n directions(input: $input) {\n routes {\n distance\n duration\n elevation {\n altitude {\n max\n min\n }\n ascent\n descent\n gradient {\n max\n min\n }\n }\n geometry\n analysis {\n elevation {\n altitude {\n max\n min\n }\n ascent\n descent\n gradient {\n max\n min\n }\n }\n elevations\n slopeInfo {\n fromIndex\n toIndex\n value\n }\n speedInfo {\n fromIndex\n toIndex\n value\n }\n surfaceInfo {\n fromIndex\n toIndex\n value\n }\n trailDifficultyInfo {\n fromIndex\n toIndex\n value\n }\n wayTypeInfo {\n fromIndex\n toIndex\n value\n }\n advisories {\n tollway\n restrictedAccess\n tollwayInfo {\n fromIndex\n toIndex\n value\n }\n roadAccessInfo {\n fromIndex\n toIndex\n values\n }\n }\n }\n avoidance\n summary\n steps {\n fromIndex\n toIndex\n type\n name\n distance\n duration\n exitNumber\n }\n }\n }\n}\n",
|
|
2384
|
+
options?.select
|
|
2385
|
+
),
|
|
2386
|
+
input,
|
|
2387
|
+
options
|
|
2388
|
+
);
|
|
2389
|
+
var exportItinerary = (transport, input, options) => runOperation(
|
|
2390
|
+
transport,
|
|
2391
|
+
"exportItinerary",
|
|
2392
|
+
documentFor(
|
|
2393
|
+
"exportItinerary",
|
|
2394
|
+
"ExportItineraryInput!",
|
|
2395
|
+
exportItineraryFields,
|
|
2396
|
+
"query ExportItinerary($input: ExportItineraryInput!) {\n exportItinerary(input: $input) {\n url\n filename\n format\n expiresAt\n }\n}\n",
|
|
2397
|
+
options?.select
|
|
2398
|
+
),
|
|
2399
|
+
input,
|
|
2400
|
+
options,
|
|
2401
|
+
{ expiresAt: true }
|
|
2402
|
+
);
|
|
2403
|
+
var geocode = (transport, input, options) => runOperation(
|
|
2404
|
+
transport,
|
|
2405
|
+
"geocode",
|
|
2406
|
+
documentFor(
|
|
2407
|
+
"geocode",
|
|
2408
|
+
"GeocodeInput!",
|
|
2409
|
+
geocodeFields,
|
|
2410
|
+
"query Geocode($input: GeocodeInput!) {\n geocode(input: $input) {\n count\n places {\n osm {\n id\n type\n key\n value\n }\n name\n label\n layer\n category\n point\n bounds\n country\n countryName\n region\n county\n city\n postcode\n street\n houseNumber\n }\n }\n}\n",
|
|
2411
|
+
options?.select
|
|
2412
|
+
),
|
|
2413
|
+
input,
|
|
2414
|
+
options
|
|
2415
|
+
);
|
|
2416
|
+
var isochrones = (transport, input, options) => runOperation(
|
|
2417
|
+
transport,
|
|
2418
|
+
"isochrones",
|
|
2419
|
+
documentFor(
|
|
2420
|
+
"isochrones",
|
|
2421
|
+
"IsochronesInput!",
|
|
2422
|
+
isochronesFields,
|
|
2423
|
+
"query Isochrones($input: IsochronesInput!) {\n isochrones(input: $input) {\n isochrones {\n value\n area\n reachFactor\n center\n geometry\n }\n }\n}\n",
|
|
2424
|
+
options?.select
|
|
2425
|
+
),
|
|
2426
|
+
input,
|
|
2427
|
+
options
|
|
2428
|
+
);
|
|
2429
|
+
var itinerary = (transport, input, options) => runOperation(
|
|
2430
|
+
transport,
|
|
2431
|
+
"itinerary",
|
|
2432
|
+
documentFor(
|
|
2433
|
+
"itinerary",
|
|
2434
|
+
"ItineraryInput!",
|
|
2435
|
+
itineraryFields,
|
|
2436
|
+
"query Itinerary($input: ItineraryInput!) {\n itinerary(input: $input) {\n id\n name\n description\n activitySlug\n distance\n ascent\n isPrivate\n organizationId\n segments {\n id\n name\n description\n position\n groupId\n distance\n duration\n ascent\n descent\n altitude {\n max\n min\n }\n gradient {\n max\n min\n }\n geometry\n }\n waypoints {\n id\n name\n description\n position\n point\n amenities\n timing {\n cutoffAt\n stopDuration\n }\n contact {\n website\n phone\n email\n address\n openingHours\n bookingUrl\n }\n media {\n photos {\n url\n caption\n }\n links {\n label\n url\n }\n }\n properties {\n key\n label\n value\n format\n }\n }\n groups {\n id\n name\n color\n speed\n }\n segmentCount\n waypointCount\n groupCount\n }\n}\n",
|
|
2437
|
+
options?.select
|
|
2438
|
+
),
|
|
2439
|
+
input,
|
|
2440
|
+
options,
|
|
2441
|
+
{ waypoints: [{ timing: { cutoffAt: true } }] }
|
|
2442
|
+
);
|
|
2443
|
+
var matrix = (transport, input, options) => runOperation(
|
|
2444
|
+
transport,
|
|
2445
|
+
"matrix",
|
|
2446
|
+
documentFor(
|
|
2447
|
+
"matrix",
|
|
2448
|
+
"MatrixInput!",
|
|
2449
|
+
matrixFields,
|
|
2450
|
+
"query Matrix($input: MatrixInput!) {\n matrix(input: $input) {\n durations\n distances\n }\n}\n",
|
|
2451
|
+
options?.select
|
|
2452
|
+
),
|
|
2453
|
+
input,
|
|
2454
|
+
options
|
|
2455
|
+
);
|
|
2456
|
+
var pois = (transport, input, options) => runOperation(
|
|
2457
|
+
transport,
|
|
2458
|
+
"pois",
|
|
2459
|
+
documentFor(
|
|
2460
|
+
"pois",
|
|
2461
|
+
"PoisInput!",
|
|
2462
|
+
poisFields,
|
|
2463
|
+
"query Pois($input: PoisInput!) {\n pois(input: $input) {\n count\n pois {\n osm {\n id\n type\n key\n value\n }\n name\n category\n point\n elevation\n tags {\n key\n value\n }\n distanceMeters\n country\n countryName\n region\n city\n }\n }\n}\n",
|
|
2464
|
+
options?.select
|
|
2465
|
+
),
|
|
2466
|
+
input,
|
|
2467
|
+
options
|
|
2468
|
+
);
|
|
2469
|
+
var reverseGeocode = (transport, input, options) => runOperation(
|
|
2470
|
+
transport,
|
|
2471
|
+
"reverseGeocode",
|
|
2472
|
+
documentFor(
|
|
2473
|
+
"reverseGeocode",
|
|
2474
|
+
"ReverseGeocodeInput!",
|
|
2475
|
+
reverseGeocodeFields,
|
|
2476
|
+
"query ReverseGeocode($input: ReverseGeocodeInput!) {\n reverseGeocode(input: $input) {\n point\n places {\n osm {\n id\n type\n key\n value\n }\n name\n label\n layer\n category\n point\n bounds\n country\n countryName\n region\n county\n city\n postcode\n street\n houseNumber\n }\n count\n }\n}\n",
|
|
2477
|
+
options?.select
|
|
2478
|
+
),
|
|
2479
|
+
input,
|
|
2480
|
+
options
|
|
2481
|
+
);
|
|
2482
|
+
var search = (transport, input, options) => runOperation(
|
|
2483
|
+
transport,
|
|
2484
|
+
"search",
|
|
2485
|
+
documentFor(
|
|
2486
|
+
"search",
|
|
2487
|
+
"SearchInput!",
|
|
2488
|
+
searchFields,
|
|
2489
|
+
"query Search($input: SearchInput!) {\n search(input: $input) {\n query\n language\n targets {\n places\n pois\n ways\n itineraries\n collections\n zones\n }\n places {\n count\n places {\n osm {\n id\n type\n key\n value\n }\n name\n label\n layer\n category\n point\n bounds\n country\n countryName\n region\n county\n city\n postcode\n street\n houseNumber\n }\n }\n pois {\n count\n pois {\n osm {\n id\n type\n key\n value\n }\n name\n category\n point\n elevation\n tags {\n key\n value\n }\n distanceMeters\n country\n countryName\n region\n city\n }\n }\n ways {\n count\n ways {\n osm {\n id\n type\n key\n value\n }\n name\n highway\n surface\n sacScale\n point\n bounds\n coordinates\n activityCompatible\n country\n countryName\n region\n city\n }\n activityApplied\n }\n itineraries {\n count\n itineraries {\n id\n name\n description\n distance\n ascent\n activitySlug\n start\n bounds\n isPrivate\n organizationId\n score\n matchedField\n }\n }\n collections {\n count\n collections {\n id\n name\n description\n count {\n itineraries\n zones\n }\n bounds\n isPrivate\n organizationId\n score\n matchedField\n }\n }\n zones {\n count\n zones {\n id\n name\n description\n level\n mode\n point\n bounds\n isPrivate\n organizationId\n score\n matchedField\n }\n }\n errors {\n target\n code\n message\n }\n }\n}\n",
|
|
2490
|
+
options?.select
|
|
2491
|
+
),
|
|
2492
|
+
input,
|
|
2493
|
+
options
|
|
2494
|
+
);
|
|
2495
|
+
var suggestions = (transport, input, options) => runOperation(
|
|
2496
|
+
transport,
|
|
2497
|
+
"suggestions",
|
|
2498
|
+
documentFor(
|
|
2499
|
+
"suggestions",
|
|
2500
|
+
"SuggestionsInput!",
|
|
2501
|
+
suggestionsFields,
|
|
2502
|
+
"query Suggestions($input: SuggestionsInput!) {\n suggestions(input: $input) {\n routes {\n distance\n duration\n elevation {\n altitude {\n max\n min\n }\n ascent\n descent\n gradient {\n max\n min\n }\n }\n geometry\n analysis {\n elevation {\n altitude {\n max\n min\n }\n ascent\n descent\n gradient {\n max\n min\n }\n }\n elevations\n slopeInfo {\n fromIndex\n toIndex\n value\n }\n speedInfo {\n fromIndex\n toIndex\n value\n }\n surfaceInfo {\n fromIndex\n toIndex\n value\n }\n trailDifficultyInfo {\n fromIndex\n toIndex\n value\n }\n wayTypeInfo {\n fromIndex\n toIndex\n value\n }\n advisories {\n tollway\n restrictedAccess\n tollwayInfo {\n fromIndex\n toIndex\n value\n }\n roadAccessInfo {\n fromIndex\n toIndex\n values\n }\n }\n }\n summary\n steps {\n fromIndex\n toIndex\n type\n name\n distance\n duration\n exitNumber\n }\n seed\n }\n }\n}\n",
|
|
2503
|
+
options?.select
|
|
2504
|
+
),
|
|
2505
|
+
input,
|
|
2506
|
+
options
|
|
2507
|
+
);
|
|
2508
|
+
var terrainGrid = (transport, input, options) => runOperation(
|
|
2509
|
+
transport,
|
|
2510
|
+
"terrainGrid",
|
|
2511
|
+
documentFor(
|
|
2512
|
+
"terrainGrid",
|
|
2513
|
+
"TerrainGridInput!",
|
|
2514
|
+
terrainGridFields,
|
|
2515
|
+
"query TerrainGrid($input: TerrainGridInput!) {\n terrainGrid(input: $input) {\n count\n coveredCount\n zoom\n resolutionMeters\n cols\n rows\n cells {\n point\n elevation\n slope\n aspect\n aspectOctant\n steepnessBand\n distanceMeters\n }\n }\n}\n",
|
|
2516
|
+
options?.select
|
|
2517
|
+
),
|
|
2518
|
+
input,
|
|
2519
|
+
options
|
|
2520
|
+
);
|
|
2521
|
+
var terrainProfile = (transport, input, options) => runOperation(
|
|
2522
|
+
transport,
|
|
2523
|
+
"terrainProfile",
|
|
2524
|
+
documentFor(
|
|
2525
|
+
"terrainProfile",
|
|
2526
|
+
"TerrainProfileInput!",
|
|
2527
|
+
terrainProfileFields,
|
|
2528
|
+
"query TerrainProfile($input: TerrainProfileInput!) {\n terrainProfile(input: $input) {\n count\n coveredCount\n zoom\n resolutionMeters\n samples {\n point\n elevation\n slope\n aspect\n aspectOctant\n steepnessBand\n distanceMeters\n }\n }\n}\n",
|
|
2529
|
+
options?.select
|
|
2530
|
+
),
|
|
2531
|
+
input,
|
|
2532
|
+
options
|
|
2533
|
+
);
|
|
2534
|
+
var terrainSamples = (transport, input, options) => runOperation(
|
|
2535
|
+
transport,
|
|
2536
|
+
"terrainSamples",
|
|
2537
|
+
documentFor(
|
|
2538
|
+
"terrainSamples",
|
|
2539
|
+
"TerrainSamplesInput!",
|
|
2540
|
+
terrainSamplesFields,
|
|
2541
|
+
"query TerrainSamples($input: TerrainSamplesInput!) {\n terrainSamples(input: $input) {\n count\n coveredCount\n zoom\n resolutionMeters\n samples {\n point\n elevation\n slope\n aspect\n aspectOctant\n steepnessBand\n distanceMeters\n }\n }\n}\n",
|
|
2542
|
+
options?.select
|
|
2543
|
+
),
|
|
2544
|
+
input,
|
|
2545
|
+
options
|
|
2546
|
+
);
|
|
2547
|
+
var bind = (transport) => ({
|
|
2548
|
+
/**
|
|
2549
|
+
* Analyze surface and way type of an existing geometry.
|
|
2550
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2551
|
+
* @see {@link analyzeGeometry}
|
|
2552
|
+
*/
|
|
2553
|
+
analyzeGeometry: (input, options) => analyzeGeometry(transport, input, options),
|
|
2554
|
+
/**
|
|
2555
|
+
* Compute directions between waypoints for a given activity.
|
|
2556
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2557
|
+
* @see {@link directions}
|
|
2558
|
+
*/
|
|
2559
|
+
directions: (input, options) => directions(transport, input, options),
|
|
2560
|
+
/**
|
|
2561
|
+
* Prepare a download of an itinerary in a route file format.
|
|
2562
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2563
|
+
* @see {@link exportItinerary}
|
|
2564
|
+
*/
|
|
2565
|
+
exportItinerary: (input, options) => exportItinerary(transport, input, options),
|
|
2566
|
+
/**
|
|
2567
|
+
* Forward geocode a free-text query into a list of named places.
|
|
2568
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2569
|
+
* @see {@link geocode}
|
|
2570
|
+
*/
|
|
2571
|
+
geocode: (input, options) => geocode(transport, input, options),
|
|
2572
|
+
/**
|
|
2573
|
+
* Compute isochrones (reachability polygons) from one or more locations for a given activity.
|
|
2574
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2575
|
+
* @see {@link isochrones}
|
|
2576
|
+
*/
|
|
2577
|
+
isochrones: (input, options) => isochrones(transport, input, options),
|
|
2578
|
+
/**
|
|
2579
|
+
* Read a single itinerary by identifier, with its ordered segments and waypoints.
|
|
2580
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2581
|
+
* @see {@link itinerary}
|
|
2582
|
+
*/
|
|
2583
|
+
itinerary: (input, options) => itinerary(transport, input, options),
|
|
2584
|
+
/**
|
|
2585
|
+
* Compute a time-distance matrix between locations for a given activity.
|
|
2586
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2587
|
+
* @see {@link matrix}
|
|
2588
|
+
*/
|
|
2589
|
+
matrix: (input, options) => matrix(transport, input, options),
|
|
2590
|
+
/**
|
|
2591
|
+
* List points-of-interest matching one or more categories inside a bounding box or a buffered geometry.
|
|
2592
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2593
|
+
* @see {@link pois}
|
|
2594
|
+
*/
|
|
2595
|
+
pois: (input, options) => pois(transport, input, options),
|
|
2596
|
+
/**
|
|
2597
|
+
* Reverse geocode a [longitude, latitude] point into a list of named places.
|
|
2598
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2599
|
+
* @see {@link reverseGeocode}
|
|
2600
|
+
*/
|
|
2601
|
+
reverseGeocode: (input, options) => reverseGeocode(transport, input, options),
|
|
2602
|
+
/**
|
|
2603
|
+
* Unified full-text search across geocoded places, POIs, ways, and Mountaya entities (itineraries, collections, zones).
|
|
2604
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope through Mountaya's MCP server, and a session token.
|
|
2605
|
+
* @see {@link search}
|
|
2606
|
+
*/
|
|
2607
|
+
search: (input, options) => search(transport, input, options),
|
|
2608
|
+
/**
|
|
2609
|
+
* Generate route suggestions matching distance constraints for a given activity.
|
|
2610
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2611
|
+
* @see {@link suggestions}
|
|
2612
|
+
*/
|
|
2613
|
+
suggestions: (input, options) => suggestions(transport, input, options),
|
|
2614
|
+
/**
|
|
2615
|
+
* Sample the surface over a rectangular grid inside a bounding box, for area reconnaissance: finding high ground, a steep band, or a slope facing a given direction before routing through it.
|
|
2616
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2617
|
+
* @see {@link terrainGrid}
|
|
2618
|
+
*/
|
|
2619
|
+
terrainGrid: (input, options) => terrainGrid(transport, input, options),
|
|
2620
|
+
/**
|
|
2621
|
+
* Sample the surface along a geometry at a fixed interval, producing an elevation profile as data.
|
|
2622
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2623
|
+
* @see {@link terrainProfile}
|
|
2624
|
+
*/
|
|
2625
|
+
terrainProfile: (input, options) => terrainProfile(transport, input, options),
|
|
2626
|
+
/**
|
|
2627
|
+
* Sample elevation, slope, and aspect at standalone [longitude, latitude] points.
|
|
2628
|
+
* Requires a publishable key with the DATA scope, or with the MCP scope when the call arrives through Mountaya's MCP server, and a session token.
|
|
2629
|
+
* @see {@link terrainSamples}
|
|
2630
|
+
*/
|
|
2631
|
+
terrainSamples: (input, options) => terrainSamples(transport, input, options)
|
|
2632
|
+
});
|
|
2633
|
+
|
|
2634
|
+
// src/tiles/operations.gen.ts
|
|
2635
|
+
var operations_gen_exports2 = {};
|
|
2636
|
+
__export(operations_gen_exports2, {
|
|
2637
|
+
bind: () => bind2,
|
|
2638
|
+
getCollectionSpecification: () => getCollectionSpecification,
|
|
2639
|
+
getItinerariesSpecification: () => getItinerariesSpecification,
|
|
2640
|
+
getItinerarySpecification: () => getItinerarySpecification,
|
|
2641
|
+
getOverlaySpecification: () => getOverlaySpecification,
|
|
2642
|
+
getTileLayers: () => getTileLayers,
|
|
2643
|
+
getZonesSpecification: () => getZonesSpecification
|
|
2644
|
+
});
|
|
2645
|
+
var getCollectionSpecification = (transport, args, options) => transport.request({
|
|
2646
|
+
acceptsShareToken: true,
|
|
2647
|
+
idempotent: true,
|
|
2648
|
+
method: "GET",
|
|
2649
|
+
operationId: "getCollectionSpecification",
|
|
2650
|
+
path: `/v1/collections/${encodeURIComponent(String(args.collection_id))}/specification`,
|
|
2651
|
+
query: args.query,
|
|
2652
|
+
retry: options?.retry,
|
|
2653
|
+
serverBudgetMs: 3e4,
|
|
2654
|
+
signal: options?.signal,
|
|
2655
|
+
surface: "tiles",
|
|
2656
|
+
timeoutMs: options?.timeoutMs
|
|
2657
|
+
});
|
|
2658
|
+
var getItinerariesSpecification = (transport, options) => transport.request({
|
|
2659
|
+
acceptsShareToken: true,
|
|
2660
|
+
idempotent: true,
|
|
2661
|
+
method: "GET",
|
|
2662
|
+
operationId: "getItinerariesSpecification",
|
|
2663
|
+
path: "/v1/itineraries/specification",
|
|
2664
|
+
retry: options?.retry,
|
|
2665
|
+
serverBudgetMs: 3e4,
|
|
2666
|
+
signal: options?.signal,
|
|
2667
|
+
surface: "tiles",
|
|
2668
|
+
timeoutMs: options?.timeoutMs
|
|
2669
|
+
});
|
|
2670
|
+
var getItinerarySpecification = (transport, args, options) => transport.request({
|
|
2671
|
+
acceptsShareToken: true,
|
|
2672
|
+
idempotent: true,
|
|
2673
|
+
method: "GET",
|
|
2674
|
+
operationId: "getItinerarySpecification",
|
|
2675
|
+
path: `/v1/itineraries/${encodeURIComponent(String(args.itinerary_id))}/specification`,
|
|
2676
|
+
retry: options?.retry,
|
|
2677
|
+
serverBudgetMs: 3e4,
|
|
2678
|
+
signal: options?.signal,
|
|
2679
|
+
surface: "tiles",
|
|
2680
|
+
timeoutMs: options?.timeoutMs
|
|
2681
|
+
});
|
|
2682
|
+
var getOverlaySpecification = (transport, args, options) => transport.request({
|
|
2683
|
+
acceptsShareToken: true,
|
|
2684
|
+
idempotent: true,
|
|
2685
|
+
method: "GET",
|
|
2686
|
+
operationId: "getOverlaySpecification",
|
|
2687
|
+
path: `/v1/overlays/${encodeURIComponent(String(args.overlay))}/specification`,
|
|
2688
|
+
query: args.query,
|
|
2689
|
+
retry: options?.retry,
|
|
2690
|
+
serverBudgetMs: 3e4,
|
|
2691
|
+
signal: options?.signal,
|
|
2692
|
+
surface: "tiles",
|
|
2693
|
+
timeoutMs: options?.timeoutMs
|
|
2694
|
+
});
|
|
2695
|
+
var getTileLayers = (transport, args = {}, options) => transport.request({
|
|
2696
|
+
acceptsShareToken: true,
|
|
2697
|
+
idempotent: true,
|
|
2698
|
+
method: "GET",
|
|
2699
|
+
operationId: "getTileLayers",
|
|
2700
|
+
path: "/v1/tile-layers",
|
|
2701
|
+
query: args.query,
|
|
2702
|
+
retry: options?.retry,
|
|
2703
|
+
serverBudgetMs: 3e4,
|
|
2704
|
+
signal: options?.signal,
|
|
2705
|
+
surface: "tiles",
|
|
2706
|
+
timeoutMs: options?.timeoutMs
|
|
2707
|
+
});
|
|
2708
|
+
var getZonesSpecification = (transport, options) => transport.request({
|
|
2709
|
+
acceptsShareToken: true,
|
|
2710
|
+
idempotent: true,
|
|
2711
|
+
method: "GET",
|
|
2712
|
+
operationId: "getZonesSpecification",
|
|
2713
|
+
path: "/v1/zones/specification",
|
|
2714
|
+
retry: options?.retry,
|
|
2715
|
+
serverBudgetMs: 3e4,
|
|
2716
|
+
signal: options?.signal,
|
|
2717
|
+
surface: "tiles",
|
|
2718
|
+
timeoutMs: options?.timeoutMs
|
|
2719
|
+
});
|
|
2720
|
+
var bind2 = (transport) => ({
|
|
2721
|
+
/**
|
|
2722
|
+
* Retrieve the tile specification for a collection.
|
|
2723
|
+
* GET /v1/collections/{collection_id}/specification
|
|
2724
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2725
|
+
* @see {@link getCollectionSpecification}
|
|
2726
|
+
*/
|
|
2727
|
+
getCollectionSpecification: (args, options) => getCollectionSpecification(transport, args, options),
|
|
2728
|
+
/**
|
|
2729
|
+
* Retrieve the tile specification for the organization's itineraries.
|
|
2730
|
+
* GET /v1/itineraries/specification
|
|
2731
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2732
|
+
* @see {@link getItinerariesSpecification}
|
|
2733
|
+
*/
|
|
2734
|
+
getItinerariesSpecification: (options) => getItinerariesSpecification(transport, options),
|
|
2735
|
+
/**
|
|
2736
|
+
* Retrieve the tile specification for a single itinerary.
|
|
2737
|
+
* GET /v1/itineraries/{itinerary_id}/specification
|
|
2738
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2739
|
+
* @see {@link getItinerarySpecification}
|
|
2740
|
+
*/
|
|
2741
|
+
getItinerarySpecification: (args, options) => getItinerarySpecification(transport, args, options),
|
|
2742
|
+
/**
|
|
2743
|
+
* Retrieve the tile specification for a map overlay.
|
|
2744
|
+
* GET /v1/overlays/{overlay}/specification
|
|
2745
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2746
|
+
* @see {@link getOverlaySpecification}
|
|
2747
|
+
*/
|
|
2748
|
+
getOverlaySpecification: (args, options) => getOverlaySpecification(transport, args, options),
|
|
2749
|
+
/**
|
|
2750
|
+
* List the terrains, overlays and layers this API draws.
|
|
2751
|
+
* GET /v1/tile-layers
|
|
2752
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2753
|
+
* @see {@link getTileLayers}
|
|
2754
|
+
*/
|
|
2755
|
+
getTileLayers: (args, options) => getTileLayers(transport, args, options),
|
|
2756
|
+
/**
|
|
2757
|
+
* Retrieve the tile specification for the organization's zones.
|
|
2758
|
+
* GET /v1/zones/specification
|
|
2759
|
+
* Requires a publishable key with the `tiles` scope.
|
|
2760
|
+
* @see {@link getZonesSpecification}
|
|
2761
|
+
*/
|
|
2762
|
+
getZonesSpecification: (options) => getZonesSpecification(transport, options)
|
|
2763
|
+
});
|
|
2764
|
+
|
|
2765
|
+
// src/core/rules/sessionAnswer.ts
|
|
2766
|
+
var REMEDY = "Answer the { token, expires_at, user_id } that POST /v1/sessions returns, and reject where your endpoint fails, as a mint that checks the response's status does.";
|
|
2767
|
+
var isDate = (value) => Object.prototype.toString.call(value) === "[object Date]";
|
|
2768
|
+
var readSessionAnswer = (answer) => {
|
|
2769
|
+
if (typeof answer !== "object" || answer === null) {
|
|
2770
|
+
throw new MountayaConnectionError(
|
|
2771
|
+
`mint: the answer is ${describeType(answer)}, so it is no session. ${REMEDY}`
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
const token = Reflect.get(answer, "token");
|
|
2775
|
+
if (typeof token !== "string" || token === "") {
|
|
2776
|
+
throw new MountayaConnectionError(
|
|
2777
|
+
`mint: the answer holds no token (token is ${token === "" ? "an empty string" : describeType(token)}), so it is no session. ${REMEDY}`
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2780
|
+
const expiry = Reflect.get(answer, "expires_at");
|
|
2781
|
+
if (typeof expiry !== "string" && typeof expiry !== "number" && !isDate(expiry)) {
|
|
2782
|
+
throw new MountayaConnectionError(
|
|
2783
|
+
`mint: the answer holds no expiry to read (expires_at is ${describeType(expiry)}), so it is no session. ${REMEDY}`
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
const parsed = new Date(expiry);
|
|
2787
|
+
const user = Reflect.get(answer, "user_id");
|
|
2788
|
+
return {
|
|
2789
|
+
expiresAt: Number.isNaN(parsed.getTime()) ? void 0 : parsed,
|
|
2790
|
+
token,
|
|
2791
|
+
userId: typeof user === "string" && user !== "" ? user : user === null ? null : void 0
|
|
2792
|
+
};
|
|
2793
|
+
};
|
|
2794
|
+
|
|
2795
|
+
// src/core/rules/sessionSchedule.ts
|
|
2796
|
+
var REFRESH_MARGIN_MS = 6e4;
|
|
2797
|
+
var MAX_TIMER_MS = 10 * 6e4;
|
|
2798
|
+
var MIN_TIMER_MS = 5e3;
|
|
2799
|
+
var refreshSchedule = ({
|
|
2800
|
+
consecutiveSpent,
|
|
2801
|
+
lifetimeMs
|
|
2802
|
+
}) => {
|
|
2803
|
+
if (consecutiveSpent !== void 0) {
|
|
2804
|
+
return {
|
|
2805
|
+
armed: true,
|
|
2806
|
+
delayMs: Math.min(REFRESH_MARGIN_MS, MIN_TIMER_MS * 2 ** (consecutiveSpent - 1))
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
if (lifetimeMs === void 0) {
|
|
2810
|
+
return { armed: true, delayMs: REFRESH_MARGIN_MS };
|
|
2811
|
+
}
|
|
2812
|
+
const delayMs = lifetimeMs - Math.min(REFRESH_MARGIN_MS, lifetimeMs / 2);
|
|
2813
|
+
return { armed: delayMs >= MIN_TIMER_MS, delayMs };
|
|
2814
|
+
};
|
|
2815
|
+
|
|
2816
|
+
// src/core/engines/sessionToken.ts
|
|
2817
|
+
var CONTEXT = "SessionTokenEngine";
|
|
2818
|
+
var assertMint = (mint) => {
|
|
2819
|
+
if (typeof mint !== "function") {
|
|
2820
|
+
throw refuseOption(
|
|
2821
|
+
"mint",
|
|
2822
|
+
mint,
|
|
2823
|
+
"pass a function that calls your session endpoint and answers its { token, expires_at, user_id }.",
|
|
2824
|
+
CONTEXT
|
|
2825
|
+
);
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
var assertEnabled = (enabled) => {
|
|
2829
|
+
if (enabled !== void 0 && typeof enabled !== "boolean") {
|
|
2830
|
+
throw refuseOption(
|
|
2831
|
+
"enabled",
|
|
2832
|
+
enabled,
|
|
2833
|
+
"pass true to mint, false to stop, or leave it out to mint.",
|
|
2834
|
+
CONTEXT
|
|
2835
|
+
);
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
var snapshotOf = (fields) => printsAs({ ...fields }, (snapshot) => ({
|
|
2839
|
+
...snapshot,
|
|
2840
|
+
token: snapshot.token === void 0 ? void 0 : redactedSessionToken(snapshot.token)
|
|
2841
|
+
}));
|
|
2842
|
+
var emptySnapshot = snapshotOf({
|
|
2843
|
+
error: void 0,
|
|
2844
|
+
expiresAt: void 0,
|
|
2845
|
+
isLoading: false,
|
|
2846
|
+
token: void 0,
|
|
2847
|
+
userId: void 0
|
|
2848
|
+
});
|
|
2849
|
+
var isCancellation = (failure) => typeof failure === "object" && failure !== null && "name" in failure && failure.name === "AbortError";
|
|
2850
|
+
var abortedByApplication = ({ controller: { signal } }) => signal.aborted && !(typeof signal.reason === "object" && signal.reason !== null && "name" in signal.reason && signal.reason.name === "TimeoutError");
|
|
2851
|
+
var surfaceFault2 = (fault) => {
|
|
2852
|
+
queueMicrotask(() => {
|
|
2853
|
+
throw fault;
|
|
2854
|
+
});
|
|
2855
|
+
};
|
|
2856
|
+
var SessionTokenEngine = class {
|
|
2857
|
+
mintFn;
|
|
2858
|
+
enabled;
|
|
2859
|
+
snapshot;
|
|
2860
|
+
listeners = /* @__PURE__ */ new Set();
|
|
2861
|
+
/**
|
|
2862
|
+
* Whether anything is watching. An engine with no listener mints nothing: {@link
|
|
2863
|
+
* SessionTokenEngine.subscribe} says why that is the lifecycle rather than a method pair.
|
|
2864
|
+
*/
|
|
2865
|
+
parked = true;
|
|
2866
|
+
/** The latch an owner that is not a component closes. See {@link dispose}. */
|
|
2867
|
+
disposed = false;
|
|
2868
|
+
/**
|
|
2869
|
+
* Whether the application cancelled the last mint, which ended that run of minting: nothing is
|
|
2870
|
+
* armed and nothing mints until a refresh, a new subscriber or an enable starts a run again.
|
|
2871
|
+
*/
|
|
2872
|
+
cancelled = false;
|
|
2873
|
+
timer = null;
|
|
2874
|
+
/**
|
|
2875
|
+
* What the armed timer is for, held as the instant rather than the timer, so
|
|
2876
|
+
* {@link SessionTokenEngine.checkNow} can re-read the clock against it. Undefined where nothing
|
|
2877
|
+
* is armed.
|
|
2878
|
+
*/
|
|
2879
|
+
deadline = void 0;
|
|
2880
|
+
/**
|
|
2881
|
+
* Whether a mint of the current generation is out. It is what a refresh joins: a mint already
|
|
2882
|
+
* on its way answers the question a second one would ask.
|
|
2883
|
+
*/
|
|
2884
|
+
minting = false;
|
|
2885
|
+
/**
|
|
2886
|
+
* The mint call that has not answered yet, kept across a park so that a resume joins it rather
|
|
2887
|
+
* than calling the application's endpoint a second time. A disable and an abandonment drop it:
|
|
2888
|
+
* the next mint is then a call of its own.
|
|
2889
|
+
*/
|
|
2890
|
+
call = void 0;
|
|
2891
|
+
/**
|
|
2892
|
+
* A generation counter, so a mint still in flight when the engine parks, is disabled or
|
|
2893
|
+
* abandons it cannot write its result over a newer one. Comparing generations is what makes an
|
|
2894
|
+
* out-of-order response harmless rather than a token that goes backwards.
|
|
2895
|
+
*/
|
|
2896
|
+
generation = 0;
|
|
2897
|
+
/**
|
|
2898
|
+
* How many mints in a row have failed, been abandoned or answered a token with no usable
|
|
2899
|
+
* lifetime left, which is what the wait between them doubles on. Only a mint of the current
|
|
2900
|
+
* generation touches it, below the generation check: a retired mint must not be able to stretch
|
|
2901
|
+
* the schedule of the run that replaced it, for the same reason it must not be able to write
|
|
2902
|
+
* its token.
|
|
2903
|
+
*/
|
|
2904
|
+
backoff = 0;
|
|
2905
|
+
/**
|
|
2906
|
+
* Builds an engine over the application's `mint`. It mints nothing until something subscribes.
|
|
2907
|
+
*
|
|
2908
|
+
* @param options - The `mint` callback, and whether minting starts `enabled`.
|
|
2909
|
+
* @throws `MountayaConfigurationError` for options that are not an object, a `mint` that is not
|
|
2910
|
+
* a function, or an `enabled` that is neither a boolean nor `undefined`, naming the option and
|
|
2911
|
+
* the value.
|
|
2912
|
+
*/
|
|
2913
|
+
constructor(options) {
|
|
2914
|
+
const given = options;
|
|
2915
|
+
if (typeof given !== "object" || given === null) {
|
|
2916
|
+
throw new MountayaConfigurationError(
|
|
2917
|
+
`${CONTEXT}: options is ${describeType(given)}; pass { mint }, a function that calls your session endpoint.`
|
|
2918
|
+
);
|
|
2919
|
+
}
|
|
2920
|
+
assertMint(options.mint);
|
|
2921
|
+
assertEnabled(options.enabled);
|
|
2922
|
+
this.mintFn = options.mint;
|
|
2923
|
+
this.enabled = options.enabled ?? true;
|
|
2924
|
+
this.snapshot = this.enabled ? snapshotOf({ ...emptySnapshot, isLoading: true }) : emptySnapshot;
|
|
2925
|
+
}
|
|
2926
|
+
/** getSnapshot returns the current snapshot, by reference and stable between changes. */
|
|
2927
|
+
getSnapshot() {
|
|
2928
|
+
return this.snapshot;
|
|
2929
|
+
}
|
|
2930
|
+
/**
|
|
2931
|
+
* subscribe registers a listener for every change, and returns its own unsubscribe.
|
|
2932
|
+
*
|
|
2933
|
+
* **The listeners are the lifecycle.** A mint fires when minting is enabled and somebody is
|
|
2934
|
+
* watching; dropping the last listener retires the in-flight mint and clears the timer, and
|
|
2935
|
+
* subscribing again starts a fresh cycle. That is what a credential with nobody holding it
|
|
2936
|
+
* should do anyway, and it is the only teardown a React binding can express correctly: React
|
|
2937
|
+
* tears an effect down and sets it up again with the same object under StrictMode, so a latch
|
|
2938
|
+
* here would leave a live surface bound to a dead engine. {@link dispose} is the latch,
|
|
2939
|
+
* for an owner that is not a component.
|
|
2940
|
+
*
|
|
2941
|
+
* A fresh cycle joins the mint the park left out, where that mint has been out for less than
|
|
2942
|
+
* the refresh margin: the doubled effect of a development mount then costs the application's
|
|
2943
|
+
* endpoint one call, and the mint is still abandoned a margin after it started. A subscriber
|
|
2944
|
+
* that arrives once the application cancelled a mint starts a run of minting again, as the first
|
|
2945
|
+
* one does.
|
|
2946
|
+
*
|
|
2947
|
+
* **A binding must hand its framework a stable `subscribe`.** A fresh closure per render
|
|
2948
|
+
* unsubscribes and re-subscribes on every one, and with the lifecycle on this method that is
|
|
2949
|
+
* a mint retired and re-fired per render.
|
|
2950
|
+
*
|
|
2951
|
+
* @param listener - Called after every change of the snapshot, with no argument.
|
|
2952
|
+
* @returns The function that removes this listener, and parks the engine when it is the last.
|
|
2953
|
+
*/
|
|
2954
|
+
subscribe(listener) {
|
|
2955
|
+
this.listeners.add(listener);
|
|
2956
|
+
if ((this.parked || this.cancelled) && !this.disposed) {
|
|
2957
|
+
this.parked = false;
|
|
2958
|
+
void this.run();
|
|
2959
|
+
}
|
|
2960
|
+
return () => {
|
|
2961
|
+
this.listeners.delete(listener);
|
|
2962
|
+
if (this.listeners.size > 0 || this.parked) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
this.parked = true;
|
|
2966
|
+
this.park();
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
/**
|
|
2970
|
+
* refresh mints now, replacing any pending refresh, or joins the mint already out.
|
|
2971
|
+
*
|
|
2972
|
+
* Joining is what keeps a burst of refreshes, a retry button pressed twice or several surfaces
|
|
2973
|
+
* asking at once, to one call to the application's endpoint: the mint on its way answers every
|
|
2974
|
+
* one of them. The current token stays readable until the new one arrives, so a consumer
|
|
2975
|
+
* holding a client built from it keeps working across the call rather than losing its
|
|
2976
|
+
* credential for the duration of a round trip. A no-op while disabled or parked; once the
|
|
2977
|
+
* application cancelled a mint, it is what mints again.
|
|
2978
|
+
*
|
|
2979
|
+
* Deliberately not a backoff reset. A retry button is exactly what a user presses while the
|
|
2980
|
+
* endpoint is handing out expired tokens, so resetting here would hand them a way to hold the
|
|
2981
|
+
* interval at five seconds by pressing it: the protection is for the application's endpoint,
|
|
2982
|
+
* and a caller cannot be the one to lift it.
|
|
2983
|
+
*/
|
|
2984
|
+
refresh() {
|
|
2985
|
+
if (this.minting) {
|
|
2986
|
+
return;
|
|
2987
|
+
}
|
|
2988
|
+
void this.run();
|
|
2989
|
+
}
|
|
2990
|
+
/**
|
|
2991
|
+
* checkNow re-reads the wall clock against the armed deadline: one already passed fires now,
|
|
2992
|
+
* and one still ahead is re-armed from the clock as it reads now.
|
|
2993
|
+
*
|
|
2994
|
+
* It is what a binding calls when the page comes back (visible again, online again, restored
|
|
2995
|
+
* from the back-forward cache), because a suspended machine runs no timer. It wakes with the
|
|
2996
|
+
* clock past the deadline and the next hop still minutes away, holding a token that may have
|
|
2997
|
+
* expired during the sleep, and this replaces it before a request carries it. A mint already
|
|
2998
|
+
* out is joined: its own deadline is re-read, and it is abandoned only once it has been out
|
|
2999
|
+
* longer than the margin. A no-op while disabled, parked or disposed, and once the application
|
|
3000
|
+
* cancelled a mint, which leaves nothing armed.
|
|
3001
|
+
*
|
|
3002
|
+
* The one deadline it does not wait for is the retry of a mint that failed or was abandoned:
|
|
3003
|
+
* that mint is made now. A machine that wakes offline mints and fails, and the page coming back
|
|
3004
|
+
* online is the moment the mint can succeed, before the retry would have tried it.
|
|
3005
|
+
*/
|
|
3006
|
+
checkNow() {
|
|
3007
|
+
const deadline = this.deadline;
|
|
3008
|
+
if (!this.enabled || this.parked || this.disposed || deadline === void 0) {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
if (Date.now() < deadline.at && !deadline.retriesFailure) {
|
|
3012
|
+
this.armAt(deadline);
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
this.disarm();
|
|
3016
|
+
deadline.fire();
|
|
3017
|
+
}
|
|
3018
|
+
/**
|
|
3019
|
+
* setMint replaces the callback without disturbing the schedule.
|
|
3020
|
+
*
|
|
3021
|
+
* A binding calls this on every commit, from an effect, because the callback is usually an
|
|
3022
|
+
* inline arrow and therefore a new function each render. Replacing it must not re-mint: an
|
|
3023
|
+
* engine that restarted its cycle whenever the closure changed would loop, and the loop
|
|
3024
|
+
* reads like a server problem rather than like a dependency-list one.
|
|
3025
|
+
*
|
|
3026
|
+
* @throws `MountayaConfigurationError` for a `mint` that is not a function.
|
|
3027
|
+
*/
|
|
3028
|
+
setMint(mint) {
|
|
3029
|
+
assertMint(mint);
|
|
3030
|
+
this.mintFn = mint;
|
|
3031
|
+
}
|
|
3032
|
+
/**
|
|
3033
|
+
* setEnabled turns minting on or off.
|
|
3034
|
+
*
|
|
3035
|
+
* Disabling retires the in-flight mint, clears the timer and returns the snapshot to the
|
|
3036
|
+
* shape it had before the first mint, so a signed-out consumer cannot keep reading the
|
|
3037
|
+
* signed-in user's credential. The error goes with the token: `error` promises a retry is
|
|
3038
|
+
* scheduled, and while disabled none is. The backoff goes too: it counts one run of
|
|
3039
|
+
* unusable tokens, and a consumer signing back in later is starting a new run rather than
|
|
3040
|
+
* continuing that one.
|
|
3041
|
+
*
|
|
3042
|
+
* Setting the value it already holds does nothing, which is what lets a binding call it from
|
|
3043
|
+
* an effect without guarding.
|
|
3044
|
+
*
|
|
3045
|
+
* @throws `MountayaConfigurationError` for a value that is neither a boolean nor `undefined`,
|
|
3046
|
+
* which reads as `true`, the option's default.
|
|
3047
|
+
*/
|
|
3048
|
+
setEnabled(enabled) {
|
|
3049
|
+
const given = enabled;
|
|
3050
|
+
assertEnabled(given);
|
|
3051
|
+
const next = given !== false;
|
|
3052
|
+
if (this.enabled === next) {
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
this.enabled = next;
|
|
3056
|
+
if (!next) {
|
|
3057
|
+
this.retire();
|
|
3058
|
+
this.call = void 0;
|
|
3059
|
+
this.backoff = 0;
|
|
3060
|
+
this.commit(emptySnapshot);
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
if (this.disposed) {
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
if (!this.parked) {
|
|
3067
|
+
void this.run();
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
this.reportResting();
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* dispose retires the in-flight mint, drops the timer, clears the token and latches the
|
|
3074
|
+
* engine shut.
|
|
3075
|
+
*
|
|
3076
|
+
* For an owner that is not a component. A React binding must NOT call this: unsubscribing is
|
|
3077
|
+
* its teardown, because StrictMode tears an effect down and sets it up again with the same
|
|
3078
|
+
* object. The snapshot returns to the shape a disabled engine has, so a client whose credential
|
|
3079
|
+
* still holds the engine sends no token from here, and every listener is told of it before the
|
|
3080
|
+
* listeners are dropped.
|
|
3081
|
+
*/
|
|
3082
|
+
dispose() {
|
|
3083
|
+
if (this.disposed) {
|
|
3084
|
+
return;
|
|
3085
|
+
}
|
|
3086
|
+
this.disposed = true;
|
|
3087
|
+
this.parked = true;
|
|
3088
|
+
this.retire();
|
|
3089
|
+
this.call = void 0;
|
|
3090
|
+
this.backoff = 0;
|
|
3091
|
+
this.commit(emptySnapshot);
|
|
3092
|
+
this.listeners.clear();
|
|
3093
|
+
}
|
|
3094
|
+
// -----------------------------------------------------------------------------------------
|
|
3095
|
+
/**
|
|
3096
|
+
* commit replaces the snapshot and notifies, skipping a notification when nothing moved.
|
|
3097
|
+
*
|
|
3098
|
+
* It never throws: every listener is told, and the first fault one of them throws is handed to
|
|
3099
|
+
* {@link surfaceFault} once they all have been, so no caller here has to decide what a
|
|
3100
|
+
* listener's exception does to a mint.
|
|
3101
|
+
*/
|
|
3102
|
+
commit(next) {
|
|
3103
|
+
if (next === this.snapshot) {
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
this.snapshot = next;
|
|
3107
|
+
let fault;
|
|
3108
|
+
for (const listener of this.listeners) {
|
|
3109
|
+
try {
|
|
3110
|
+
listener();
|
|
3111
|
+
} catch (thrown) {
|
|
3112
|
+
fault ??= { thrown };
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
if (fault !== void 0) {
|
|
3116
|
+
surfaceFault2(fault.thrown);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
/** disarm drops the armed timer and the deadline it was for. */
|
|
3120
|
+
disarm() {
|
|
3121
|
+
if (this.timer !== null) {
|
|
3122
|
+
clearTimeout(this.timer);
|
|
3123
|
+
this.timer = null;
|
|
3124
|
+
}
|
|
3125
|
+
this.deadline = void 0;
|
|
3126
|
+
}
|
|
3127
|
+
/** retire drops the timer and bumps the generation, so nothing in flight can still write. */
|
|
3128
|
+
retire() {
|
|
3129
|
+
this.generation += 1;
|
|
3130
|
+
this.minting = false;
|
|
3131
|
+
this.disarm();
|
|
3132
|
+
}
|
|
3133
|
+
/** park retires whatever is in flight and reports what a request made now would wait for. */
|
|
3134
|
+
park() {
|
|
3135
|
+
this.retire();
|
|
3136
|
+
this.reportResting();
|
|
3137
|
+
}
|
|
3138
|
+
/**
|
|
3139
|
+
* reportResting sets `isLoading` for an engine nobody holds: a token is on its way where the
|
|
3140
|
+
* engine is enabled, not disposed and holds none, since its next subscriber mints at once, and
|
|
3141
|
+
* none is otherwise.
|
|
3142
|
+
*
|
|
3143
|
+
* A teardown has to set the flag itself. `run`'s own settle lowers it only for the current
|
|
3144
|
+
* generation, which is correct while a NEWER run is taking over, since that one raised the flag
|
|
3145
|
+
* for itself; but parking bumps the generation and starts nothing. Without this, a park while a
|
|
3146
|
+
* mint is out leaves the flag up with a token held, and a request made then would read a token
|
|
3147
|
+
* as both held and on its way.
|
|
3148
|
+
*/
|
|
3149
|
+
reportResting() {
|
|
3150
|
+
const onItsWay = this.enabled && !this.disposed && this.snapshot.token === void 0;
|
|
3151
|
+
if (this.snapshot.isLoading !== onItsWay) {
|
|
3152
|
+
this.commit(snapshotOf({ ...this.snapshot, isLoading: onItsWay }));
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* armAt arms a deadline, replacing whatever was armed.
|
|
3157
|
+
*
|
|
3158
|
+
* The deadline is held as an absolute instant and walked down in MAX_TIMER_MS hops, so what
|
|
3159
|
+
* survives a throttled or suspended tab is the DEADLINE rather than a timer. Each hop
|
|
3160
|
+
* re-reads the clock; the deadline fires on the first hop that finds it passed.
|
|
3161
|
+
*/
|
|
3162
|
+
armAt(deadline) {
|
|
3163
|
+
this.disarm();
|
|
3164
|
+
this.deadline = deadline;
|
|
3165
|
+
const hop = () => {
|
|
3166
|
+
const remaining = deadline.at - Date.now();
|
|
3167
|
+
if (remaining <= 0) {
|
|
3168
|
+
this.timer = null;
|
|
3169
|
+
this.deadline = void 0;
|
|
3170
|
+
deadline.fire();
|
|
3171
|
+
return;
|
|
3172
|
+
}
|
|
3173
|
+
this.timer = setTimeout(hop, Math.min(MAX_TIMER_MS, remaining));
|
|
3174
|
+
};
|
|
3175
|
+
this.timer = setTimeout(hop, Math.min(MAX_TIMER_MS, Math.max(0, deadline.at - Date.now())));
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* armRefresh arms the next mint `delay` milliseconds from now, replacing whatever was armed.
|
|
3179
|
+
* `retriesFailure` marks the wait after a mint that failed or was abandoned.
|
|
3180
|
+
*/
|
|
3181
|
+
armRefresh(delay, retriesFailure = false) {
|
|
3182
|
+
this.armAt({
|
|
3183
|
+
at: Date.now() + delay,
|
|
3184
|
+
fire: () => {
|
|
3185
|
+
void this.run();
|
|
3186
|
+
},
|
|
3187
|
+
retriesFailure
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3190
|
+
/**
|
|
3191
|
+
* callOut answers the mint call a park left out, where a run can still join it: one that
|
|
3192
|
+
* started less than a margin ago. A call out for a margin or longer is the one {@link abandon}
|
|
3193
|
+
* gives up on, so it is not joined.
|
|
3194
|
+
*/
|
|
3195
|
+
callOut() {
|
|
3196
|
+
const out = this.call;
|
|
3197
|
+
return out !== void 0 && Date.now() - out.startedAt < REFRESH_MARGIN_MS ? out : void 0;
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* startCall calls the application's mint with the controller the call runs under, and holds the
|
|
3201
|
+
* call until it answers. A mint that throws rather than rejecting is read as one that rejected.
|
|
3202
|
+
*/
|
|
3203
|
+
startCall() {
|
|
3204
|
+
const controller = new AbortController();
|
|
3205
|
+
let answer;
|
|
3206
|
+
try {
|
|
3207
|
+
answer = Promise.resolve(this.mintFn(controller));
|
|
3208
|
+
} catch (cause) {
|
|
3209
|
+
answer = Promise.reject(cause);
|
|
3210
|
+
}
|
|
3211
|
+
const call = { answer, controller, startedAt: Date.now() };
|
|
3212
|
+
this.call = call;
|
|
3213
|
+
const settle = () => {
|
|
3214
|
+
if (this.call === call) {
|
|
3215
|
+
this.call = void 0;
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
answer.then(settle, settle);
|
|
3219
|
+
return call;
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* abandon gives up on the mint of `generation`, still out a margin after it started: it is
|
|
3223
|
+
* retired so a late answer writes nothing, the failure is recorded, and a mint is tried again
|
|
3224
|
+
* as after one that failed outright, the abandoned mint counting in the same run.
|
|
3225
|
+
*
|
|
3226
|
+
* The margin is the bound because it is the headroom a token is refreshed with: a mint out for
|
|
3227
|
+
* longer has cost the token that headroom, and one that never settles would otherwise hold the
|
|
3228
|
+
* engine loading, with nothing scheduled, until the token lapsed.
|
|
3229
|
+
*/
|
|
3230
|
+
abandon(generation) {
|
|
3231
|
+
if (generation !== this.generation) {
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
this.retire();
|
|
3235
|
+
this.call = void 0;
|
|
3236
|
+
this.backoff += 1;
|
|
3237
|
+
const delayMs = refreshSchedule({ consecutiveSpent: this.backoff }).delayMs;
|
|
3238
|
+
this.armRefresh(delayMs, true);
|
|
3239
|
+
this.commit(
|
|
3240
|
+
snapshotOf({
|
|
3241
|
+
...this.snapshot,
|
|
3242
|
+
error: new MountayaConnectionError(
|
|
3243
|
+
`mint: no answer within ${REFRESH_MARGIN_MS} ms, so the mint is abandoned and tried again in ${delayMs} ms. Check that the endpoint it calls answers.`
|
|
3244
|
+
),
|
|
3245
|
+
isLoading: false
|
|
3246
|
+
})
|
|
3247
|
+
);
|
|
3248
|
+
}
|
|
3249
|
+
/** run mints once and schedules the next attempt from what came back. */
|
|
3250
|
+
async run() {
|
|
3251
|
+
if (!this.enabled || this.parked || this.disposed) {
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
this.cancelled = false;
|
|
3255
|
+
this.generation += 1;
|
|
3256
|
+
const generation = this.generation;
|
|
3257
|
+
const isCurrent = () => this.generation === generation;
|
|
3258
|
+
this.minting = true;
|
|
3259
|
+
const joined = this.callOut();
|
|
3260
|
+
this.armAt({
|
|
3261
|
+
at: (joined?.startedAt ?? Date.now()) + REFRESH_MARGIN_MS,
|
|
3262
|
+
fire: () => {
|
|
3263
|
+
this.abandon(generation);
|
|
3264
|
+
},
|
|
3265
|
+
retriesFailure: false
|
|
3266
|
+
});
|
|
3267
|
+
this.commit(snapshotOf({ ...this.snapshot, isLoading: true }));
|
|
3268
|
+
if (!isCurrent()) {
|
|
3269
|
+
return;
|
|
3270
|
+
}
|
|
3271
|
+
const call = joined ?? this.startCall();
|
|
3272
|
+
let session;
|
|
3273
|
+
try {
|
|
3274
|
+
session = readSessionAnswer(await call.answer);
|
|
3275
|
+
} catch (cause) {
|
|
3276
|
+
if (!isCurrent()) {
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
this.minting = false;
|
|
3280
|
+
if (isCancellation(cause) || abortedByApplication(call)) {
|
|
3281
|
+
this.disarm();
|
|
3282
|
+
this.cancelled = true;
|
|
3283
|
+
this.commit(snapshotOf({ ...this.snapshot, error: cause, isLoading: false }));
|
|
3284
|
+
return;
|
|
3285
|
+
}
|
|
3286
|
+
this.backoff += 1;
|
|
3287
|
+
this.armRefresh(refreshSchedule({ consecutiveSpent: this.backoff }).delayMs, true);
|
|
3288
|
+
this.commit(snapshotOf({ ...this.snapshot, error: cause, isLoading: false }));
|
|
3289
|
+
return;
|
|
3290
|
+
}
|
|
3291
|
+
if (!isCurrent()) {
|
|
3292
|
+
return;
|
|
3293
|
+
}
|
|
3294
|
+
this.minting = false;
|
|
3295
|
+
const expiry = session.expiresAt;
|
|
3296
|
+
this.commit(
|
|
3297
|
+
snapshotOf({
|
|
3298
|
+
error: void 0,
|
|
3299
|
+
expiresAt: expiry,
|
|
3300
|
+
isLoading: false,
|
|
3301
|
+
token: session.token,
|
|
3302
|
+
userId: session.userId
|
|
3303
|
+
})
|
|
3304
|
+
);
|
|
3305
|
+
if (!isCurrent()) {
|
|
3306
|
+
return;
|
|
3307
|
+
}
|
|
3308
|
+
const lifetime = expiry === void 0 ? void 0 : expiry.getTime() - Date.now();
|
|
3309
|
+
const schedule = refreshSchedule({ lifetimeMs: lifetime });
|
|
3310
|
+
if (schedule.armed) {
|
|
3311
|
+
this.backoff = 0;
|
|
3312
|
+
this.armRefresh(schedule.delayMs);
|
|
3313
|
+
return;
|
|
3314
|
+
}
|
|
3315
|
+
this.backoff += 1;
|
|
3316
|
+
this.armRefresh(refreshSchedule({ consecutiveSpent: this.backoff }).delayMs);
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
|
|
3320
|
+
// src/core/rules/paginate.ts
|
|
3321
|
+
var MAX_PAGE_SIZE = 100;
|
|
3322
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
3323
|
+
var CONTEXT2 = "paginate";
|
|
3324
|
+
var wholeNumberOption = (name, value, max, fallback) => {
|
|
3325
|
+
if (value === void 0) {
|
|
3326
|
+
return fallback;
|
|
3327
|
+
}
|
|
3328
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= max) {
|
|
3329
|
+
return value;
|
|
3330
|
+
}
|
|
3331
|
+
const range = Number.isFinite(max) ? `from 1 to ${max}` : "of 1 or more";
|
|
3332
|
+
const omitted = Number.isFinite(fallback) ? `for the default of ${fallback}` : "to walk to the listing's last page";
|
|
3333
|
+
throw refuseOption(
|
|
3334
|
+
name,
|
|
3335
|
+
value,
|
|
3336
|
+
`pass a whole number ${range}, or leave it out ${omitted}.`,
|
|
3337
|
+
CONTEXT2
|
|
3338
|
+
);
|
|
3339
|
+
};
|
|
3340
|
+
var pageOf = (answer) => {
|
|
3341
|
+
const rows = answer?.data;
|
|
3342
|
+
const next = answer?.extensions?.metadata?.pagination?.next_cursor;
|
|
3343
|
+
if (!Array.isArray(rows) || typeof next !== "string" && next !== null) {
|
|
3344
|
+
throw new MountayaConfigurationError(
|
|
3345
|
+
`${CONTEXT2}: the operation answered no page: a paged listing answers a list at data and a cursor or null at extensions.metadata.pagination.next_cursor. Pass an operation that takes cursor and limit under query.`
|
|
3346
|
+
);
|
|
3347
|
+
}
|
|
3348
|
+
return { next, rows };
|
|
3349
|
+
};
|
|
3350
|
+
var paginate = (operation, args, options = {}) => {
|
|
3351
|
+
if (typeof operation !== "function") {
|
|
3352
|
+
throw refuseOption(
|
|
3353
|
+
"operation",
|
|
3354
|
+
operation,
|
|
3355
|
+
"pass a method of the client that takes cursor and limit under query, such as mountaya.studio.itineraries.getItineraries.",
|
|
3356
|
+
CONTEXT2
|
|
3357
|
+
);
|
|
3358
|
+
}
|
|
3359
|
+
if (typeof args !== "object" || args === null) {
|
|
3360
|
+
throw refuseOption(
|
|
3361
|
+
"args",
|
|
3362
|
+
args,
|
|
3363
|
+
"pass the operation's own arguments as an object, {} where it takes none.",
|
|
3364
|
+
CONTEXT2
|
|
3365
|
+
);
|
|
3366
|
+
}
|
|
3367
|
+
if (typeof options !== "object" || options === null) {
|
|
3368
|
+
throw refuseOption(
|
|
3369
|
+
"options",
|
|
3370
|
+
options,
|
|
3371
|
+
"pass an object such as { pageSize: 25 }, or leave it out for the defaults.",
|
|
3372
|
+
CONTEXT2
|
|
3373
|
+
);
|
|
3374
|
+
}
|
|
3375
|
+
const pageSize = wholeNumberOption(
|
|
3376
|
+
"pageSize",
|
|
3377
|
+
options.pageSize,
|
|
3378
|
+
MAX_PAGE_SIZE,
|
|
3379
|
+
DEFAULT_PAGE_SIZE
|
|
3380
|
+
);
|
|
3381
|
+
const maxPages = wholeNumberOption(
|
|
3382
|
+
"maxPages",
|
|
3383
|
+
options.maxPages,
|
|
3384
|
+
Number.POSITIVE_INFINITY,
|
|
3385
|
+
Number.POSITIVE_INFINITY
|
|
3386
|
+
);
|
|
3387
|
+
const { retry, signal, timeoutMs } = options;
|
|
3388
|
+
const written = "query" in args && typeof args.query === "object" && args.query !== null ? { ...args.query } : void 0;
|
|
3389
|
+
const { cursor: start, limit: _replaced, ...query } = written ?? {};
|
|
3390
|
+
return {
|
|
3391
|
+
async *[Symbol.asyncIterator]() {
|
|
3392
|
+
let cursor = typeof start === "string" ? start : void 0;
|
|
3393
|
+
const sent = /* @__PURE__ */ new Set();
|
|
3394
|
+
for (let requested = 0; requested < maxPages; requested += 1) {
|
|
3395
|
+
if (signal?.aborted === true) {
|
|
3396
|
+
throw abortReasonOf(signal);
|
|
3397
|
+
}
|
|
3398
|
+
sent.add(cursor);
|
|
3399
|
+
const { next, rows } = pageOf(
|
|
3400
|
+
await operation(
|
|
3401
|
+
{
|
|
3402
|
+
...args,
|
|
3403
|
+
query: { ...query, ...cursor === void 0 ? {} : { cursor }, limit: pageSize }
|
|
3404
|
+
},
|
|
3405
|
+
{ retry, signal, timeoutMs }
|
|
3406
|
+
)
|
|
3407
|
+
);
|
|
3408
|
+
for (const row of rows) {
|
|
3409
|
+
yield row;
|
|
3410
|
+
}
|
|
3411
|
+
if (next === null) {
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3414
|
+
if (sent.has(next)) {
|
|
3415
|
+
throw new MountayaApiError(
|
|
3416
|
+
`${CONTEXT2}: the listing named the cursor ${JSON.stringify(next)} again, which this walk already followed, so following it would read the listing again without end. Read the listing again from its start.`,
|
|
3417
|
+
200,
|
|
3418
|
+
[]
|
|
3419
|
+
);
|
|
3420
|
+
}
|
|
3421
|
+
cursor = next;
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
};
|
|
3426
|
+
|
|
3427
|
+
// src/core/rules/version.gen.ts
|
|
3428
|
+
var SCHEMA_VERSION = "v0.9.0";
|
|
3429
|
+
|
|
3430
|
+
// src/rest/coreOperations.gen.ts
|
|
3431
|
+
var coreOperations_gen_exports = {};
|
|
3432
|
+
__export(coreOperations_gen_exports, {
|
|
3433
|
+
deleteCollection: () => deleteCollection,
|
|
3434
|
+
deleteCollectionItinerary: () => deleteCollectionItinerary,
|
|
3435
|
+
deleteCollectionShareLink: () => deleteCollectionShareLink,
|
|
3436
|
+
deleteCollectionZone: () => deleteCollectionZone,
|
|
3437
|
+
deleteItinerary: () => deleteItinerary,
|
|
3438
|
+
deleteItineraryPublication: () => deleteItineraryPublication,
|
|
3439
|
+
deleteItinerarySegment: () => deleteItinerarySegment,
|
|
3440
|
+
deleteItinerarySegmentGroup: () => deleteItinerarySegmentGroup,
|
|
3441
|
+
deleteItineraryShareLink: () => deleteItineraryShareLink,
|
|
3442
|
+
deleteItineraryWaypoint: () => deleteItineraryWaypoint,
|
|
3443
|
+
deleteZone: () => deleteZone,
|
|
3444
|
+
deleteZonePublication: () => deleteZonePublication,
|
|
3445
|
+
getActivities: () => getActivities,
|
|
3446
|
+
getAgentRunEvents: () => getAgentRunEvents,
|
|
3447
|
+
getCollection: () => getCollection,
|
|
3448
|
+
getCollectionItineraries: () => getCollectionItineraries,
|
|
3449
|
+
getCollectionShareLink: () => getCollectionShareLink,
|
|
3450
|
+
getCollectionZones: () => getCollectionZones,
|
|
3451
|
+
getCollections: () => getCollections,
|
|
3452
|
+
getItineraries: () => getItineraries,
|
|
3453
|
+
getItinerary: () => getItinerary,
|
|
3454
|
+
getItineraryEvents: () => getItineraryEvents,
|
|
3455
|
+
getItineraryExport: () => getItineraryExport,
|
|
3456
|
+
getItineraryPace: () => getItineraryPace,
|
|
3457
|
+
getItineraryShareLink: () => getItineraryShareLink,
|
|
3458
|
+
getLayers: () => getLayers,
|
|
3459
|
+
getOrganizationEvents: () => getOrganizationEvents,
|
|
3460
|
+
getZone: () => getZone,
|
|
3461
|
+
getZoneEvents: () => getZoneEvents,
|
|
3462
|
+
getZones: () => getZones,
|
|
3463
|
+
patchCollection: () => patchCollection,
|
|
3464
|
+
patchCollectionItinerary: () => patchCollectionItinerary,
|
|
3465
|
+
patchItinerary: () => patchItinerary,
|
|
3466
|
+
patchItinerarySegment: () => patchItinerarySegment,
|
|
3467
|
+
patchItinerarySegmentGroup: () => patchItinerarySegmentGroup,
|
|
3468
|
+
patchItineraryWaypoint: () => patchItineraryWaypoint,
|
|
3469
|
+
patchZone: () => patchZone,
|
|
3470
|
+
postAgentRun: () => postAgentRun,
|
|
3471
|
+
postAgentRunFeedback: () => postAgentRunFeedback,
|
|
3472
|
+
postAgentRunInput: () => postAgentRunInput,
|
|
3473
|
+
postCollection: () => postCollection,
|
|
3474
|
+
postCollectionItineraries: () => postCollectionItineraries,
|
|
3475
|
+
postCollectionShareLink: () => postCollectionShareLink,
|
|
3476
|
+
postCollectionShareLinkRotate: () => postCollectionShareLinkRotate,
|
|
3477
|
+
postCollectionZones: () => postCollectionZones,
|
|
3478
|
+
postItinerary: () => postItinerary,
|
|
3479
|
+
postItineraryCollab: () => postItineraryCollab,
|
|
3480
|
+
postItineraryDuplicate: () => postItineraryDuplicate,
|
|
3481
|
+
postItineraryImport: () => postItineraryImport,
|
|
3482
|
+
postItineraryPreview: () => postItineraryPreview,
|
|
3483
|
+
postItineraryPublication: () => postItineraryPublication,
|
|
3484
|
+
postItinerarySegment: () => postItinerarySegment,
|
|
3485
|
+
postItinerarySegmentConvert: () => postItinerarySegmentConvert,
|
|
3486
|
+
postItinerarySegmentGroup: () => postItinerarySegmentGroup,
|
|
3487
|
+
postItinerarySegmentMerge: () => postItinerarySegmentMerge,
|
|
3488
|
+
postItinerarySegmentSplit: () => postItinerarySegmentSplit,
|
|
3489
|
+
postItineraryShareLink: () => postItineraryShareLink,
|
|
3490
|
+
postItineraryShareLinkRotate: () => postItineraryShareLinkRotate,
|
|
3491
|
+
postItineraryWaypoint: () => postItineraryWaypoint,
|
|
3492
|
+
postOrganizationLookup: () => postOrganizationLookup,
|
|
3493
|
+
postZone: () => postZone,
|
|
3494
|
+
postZoneCollab: () => postZoneCollab,
|
|
3495
|
+
postZonePublication: () => postZonePublication
|
|
3496
|
+
});
|
|
3497
|
+
|
|
3498
|
+
export { MountayaSelectionError, MountayaTransport, SCHEMA_VERSION, SessionTokenEngine, bind, bind2, boundFetch, coreOperations_gen_exports, defaultBaseUrls, operations_gen_exports, operations_gen_exports2, paginate, selection_gen_exports };
|
|
3499
|
+
//# sourceMappingURL=chunk-OHKVUREN.js.map
|
|
3500
|
+
//# sourceMappingURL=chunk-OHKVUREN.js.map
|