@simpleapps-com/augur-api 2026.9.6 → 2026.9.7
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/README.md +29 -0
- package/SKILL.md +15 -0
- package/dist/{client-BdaR6MZK.d.mts → client-BbTOVex4.d.mts} +232 -21
- package/dist/{client-BdaR6MZK.d.ts → client-BbTOVex4.d.ts} +232 -21
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +384 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -146
- package/dist/index.mjs.map +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -120,6 +120,31 @@ var InvalidArgumentError = class extends AugurError {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
// src/core/client.ts
|
|
123
|
+
var MAX_ERROR_TEXT = 200;
|
|
124
|
+
function parseJson(text) {
|
|
125
|
+
try {
|
|
126
|
+
return { json: true, value: JSON.parse(text) };
|
|
127
|
+
} catch {
|
|
128
|
+
return { json: false };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function errorDetail(text) {
|
|
132
|
+
const parsed = parseJson(text);
|
|
133
|
+
if (parsed.json) {
|
|
134
|
+
const body = parsed.value;
|
|
135
|
+
const detail = typeof body === "object" && body !== null ? body : {};
|
|
136
|
+
const message = typeof detail.message === "string" && detail.message !== "" ? detail.message : void 0;
|
|
137
|
+
return { detail, message };
|
|
138
|
+
}
|
|
139
|
+
const excerpt = text.trim().slice(0, MAX_ERROR_TEXT);
|
|
140
|
+
return { detail: {}, message: excerpt === "" ? void 0 : excerpt };
|
|
141
|
+
}
|
|
142
|
+
var STATUS_ERRORS = {
|
|
143
|
+
400: (message, ctx) => new ValidationError({ message: message ?? "Validation failed", ...ctx, validationErrors: [] }),
|
|
144
|
+
401: (message, ctx) => new AuthenticationError({ message: message ?? "Authentication failed", ...ctx }),
|
|
145
|
+
404: (message, ctx) => new NotFoundError({ message: message ?? "Resource not found", ...ctx }),
|
|
146
|
+
429: (message, ctx) => new RateLimitError({ message: message ?? "Rate limit exceeded", ...ctx })
|
|
147
|
+
};
|
|
123
148
|
function generateRequestKey(method, url, params) {
|
|
124
149
|
const paramsStr = params ? JSON.stringify(params, Object.keys(params).sort()) : "";
|
|
125
150
|
return `${method}:${url}:${paramsStr}`;
|
|
@@ -190,18 +215,19 @@ var HTTPClient = class {
|
|
|
190
215
|
/**
|
|
191
216
|
* Handle non-ok fetch response: parse error, call hook, throw
|
|
192
217
|
*/
|
|
193
|
-
async handleFetchError(response, augurConfig) {
|
|
194
|
-
let
|
|
218
|
+
async handleFetchError(response, augurConfig, endpoint) {
|
|
219
|
+
let text = "";
|
|
195
220
|
try {
|
|
196
|
-
|
|
221
|
+
text = await response.text();
|
|
197
222
|
} catch {
|
|
198
223
|
}
|
|
224
|
+
const { detail, message } = errorDetail(text);
|
|
199
225
|
if (this.config.onError) {
|
|
200
226
|
const augurError = {
|
|
201
|
-
message:
|
|
227
|
+
message: message ?? `Request failed with status ${response.status}`,
|
|
202
228
|
config: augurConfig,
|
|
203
229
|
response: {
|
|
204
|
-
data:
|
|
230
|
+
data: detail,
|
|
205
231
|
status: response.status,
|
|
206
232
|
statusText: response.statusText,
|
|
207
233
|
headers: headersToRecord(response.headers),
|
|
@@ -210,7 +236,7 @@ var HTTPClient = class {
|
|
|
210
236
|
};
|
|
211
237
|
await this.config.onError(augurError);
|
|
212
238
|
}
|
|
213
|
-
this.handleHttpError(
|
|
239
|
+
this.handleHttpError(response.status, { ...detail, message }, endpoint);
|
|
214
240
|
}
|
|
215
241
|
/**
|
|
216
242
|
* Handle successful fetch response: parse, call hook, return data
|
|
@@ -231,10 +257,33 @@ var HTTPClient = class {
|
|
|
231
257
|
return responseData;
|
|
232
258
|
}
|
|
233
259
|
/**
|
|
234
|
-
*
|
|
260
|
+
* Read a successful response as text, for `raw()`. Never parses JSON.
|
|
235
261
|
*/
|
|
236
|
-
async
|
|
262
|
+
async readRaw(response, augurConfig) {
|
|
263
|
+
let text = await response.text();
|
|
264
|
+
if (this.config.onResponse) {
|
|
265
|
+
const modified = await this.config.onResponse({
|
|
266
|
+
data: text,
|
|
267
|
+
status: response.status,
|
|
268
|
+
statusText: response.statusText,
|
|
269
|
+
headers: headersToRecord(response.headers),
|
|
270
|
+
config: augurConfig
|
|
271
|
+
});
|
|
272
|
+
text = modified.data;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
status: response.status,
|
|
276
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
277
|
+
text
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Core request method using native fetch. `read` turns a 2xx response into
|
|
282
|
+
* the result, inside the same error handling and timeout as the fetch.
|
|
283
|
+
*/
|
|
284
|
+
async request(method, url, options, read = (r, c) => this.handleFetchSuccess(r, c)) {
|
|
237
285
|
const { params, data, config: requestConfig } = options;
|
|
286
|
+
const endpoint = requestConfig?.endpoint ?? url;
|
|
238
287
|
const timeout = requestConfig?.timeout ?? this.config.timeout ?? DEFAULT_CONFIG.timeout;
|
|
239
288
|
const headers = this.buildRequestHeaders(url, requestConfig);
|
|
240
289
|
let augurConfig = {
|
|
@@ -263,11 +312,11 @@ var HTTPClient = class {
|
|
|
263
312
|
}
|
|
264
313
|
const response = await fetch(fullUrl, fetchOptions);
|
|
265
314
|
if (!response.ok) {
|
|
266
|
-
await this.handleFetchError(response, augurConfig);
|
|
315
|
+
await this.handleFetchError(response, augurConfig, endpoint);
|
|
267
316
|
}
|
|
268
|
-
return
|
|
317
|
+
return await read(response, augurConfig);
|
|
269
318
|
} catch (error) {
|
|
270
|
-
this.rethrowOrWrapError(error,
|
|
319
|
+
this.rethrowOrWrapError(error, endpoint);
|
|
271
320
|
} finally {
|
|
272
321
|
clearTimeout(timeoutId);
|
|
273
322
|
}
|
|
@@ -285,37 +334,26 @@ var HTTPClient = class {
|
|
|
285
334
|
}
|
|
286
335
|
return controller.signal;
|
|
287
336
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
service: this.serviceName,
|
|
301
|
-
endpoint
|
|
302
|
-
});
|
|
303
|
-
case 429:
|
|
304
|
-
throw new RateLimitError({
|
|
305
|
-
message: data?.message || "Rate limit exceeded",
|
|
306
|
-
service: this.serviceName,
|
|
307
|
-
endpoint
|
|
308
|
-
});
|
|
309
|
-
default:
|
|
310
|
-
throw new AugurError({
|
|
311
|
-
message: data?.message || `Request failed with status ${status}`,
|
|
312
|
-
code: data?.code || "API_ERROR",
|
|
313
|
-
statusCode: status,
|
|
314
|
-
service: this.serviceName,
|
|
315
|
-
endpoint,
|
|
316
|
-
requestId: data?.requestId
|
|
317
|
-
});
|
|
337
|
+
/**
|
|
338
|
+
* The one status-to-error switch, shared by typed methods and `call()`.
|
|
339
|
+
*
|
|
340
|
+
* @ensures 400 → ValidationError, 401 → AuthenticationError, 404 → NotFoundError,
|
|
341
|
+
* 429 → RateLimitError, any other status → AugurError (the class follows the status alone)
|
|
342
|
+
* @ensures thrown.endpoint = endpoint (callers pass the path template, so no param values leak)
|
|
343
|
+
*/
|
|
344
|
+
handleHttpError(status, data, endpoint) {
|
|
345
|
+
const ctx = { service: this.serviceName, endpoint };
|
|
346
|
+
const specific = STATUS_ERRORS[status];
|
|
347
|
+
if (specific) {
|
|
348
|
+
throw specific(data.message, ctx);
|
|
318
349
|
}
|
|
350
|
+
throw new AugurError({
|
|
351
|
+
message: data.message ?? `Request failed with status ${status}`,
|
|
352
|
+
code: data.code || "API_ERROR",
|
|
353
|
+
statusCode: status,
|
|
354
|
+
...ctx,
|
|
355
|
+
requestId: data.requestId
|
|
356
|
+
});
|
|
319
357
|
}
|
|
320
358
|
/**
|
|
321
359
|
* Re-throw known error types or wrap as network error
|
|
@@ -446,6 +484,61 @@ var HTTPClient = class {
|
|
|
446
484
|
config
|
|
447
485
|
});
|
|
448
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Send a request and return the 2xx response as text, with no schema
|
|
489
|
+
* validation and no JSON assumption. Non-2xx responses throw through the same
|
|
490
|
+
* status switch as the typed methods. GET retries like `get()` (without its
|
|
491
|
+
* in-flight deduplication); other methods make one attempt, like `post()`.
|
|
492
|
+
*/
|
|
493
|
+
async raw(method, url, options = {}) {
|
|
494
|
+
const send = () => this.request(
|
|
495
|
+
method,
|
|
496
|
+
url,
|
|
497
|
+
{ ...options, params: this.transformEdgeCacheParams(options.params) },
|
|
498
|
+
(response, augurConfig) => this.readRaw(response, augurConfig)
|
|
499
|
+
);
|
|
500
|
+
return method === "GET" ? this.executeWithRetry(send) : send();
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/core/path-validation.ts
|
|
505
|
+
var normalise = (name) => name.replace(/[-_]/g, "").toLowerCase();
|
|
506
|
+
var NUMERIC_EXACT = /* @__PURE__ */ new Set(["id", "linenumber"]);
|
|
507
|
+
var NUMERIC_SUFFIX_RE = /(?:id|uid|no|num|number)$/;
|
|
508
|
+
var STRING_OVERRIDES = /* @__PURE__ */ new Set([
|
|
509
|
+
"siteid",
|
|
510
|
+
"pono",
|
|
511
|
+
"importuid",
|
|
512
|
+
"scheduledimportmasteruid",
|
|
513
|
+
"grantid",
|
|
514
|
+
"salesrepid"
|
|
515
|
+
]);
|
|
516
|
+
var isNumericPlaceholder = (placeholder) => {
|
|
517
|
+
const normalised = normalise(placeholder);
|
|
518
|
+
if (STRING_OVERRIDES.has(normalised)) return false;
|
|
519
|
+
if (NUMERIC_EXACT.has(normalised)) return true;
|
|
520
|
+
return NUMERIC_SUFFIX_RE.test(normalised);
|
|
521
|
+
};
|
|
522
|
+
var INTEGER_RE = /^-?\d+$/;
|
|
523
|
+
var PATH_SAFE_RE = /^[A-Za-z0-9\-._~!$&'()*+,;=:@]+$/;
|
|
524
|
+
var pathValueProblem = (placeholder, value) => {
|
|
525
|
+
if (isNumericPlaceholder(placeholder)) {
|
|
526
|
+
return INTEGER_RE.test(value) ? void 0 : "expected an integer";
|
|
527
|
+
}
|
|
528
|
+
if (value === "") {
|
|
529
|
+
return "expected a non-empty string";
|
|
530
|
+
}
|
|
531
|
+
return PATH_SAFE_RE.test(value) ? void 0 : "contains characters a URL path can't carry";
|
|
532
|
+
};
|
|
533
|
+
var validatePathSegment = (pathTemplate, placeholder, value, service = "http-client") => {
|
|
534
|
+
const problem = pathValueProblem(placeholder, value);
|
|
535
|
+
if (problem !== void 0) {
|
|
536
|
+
throw new InvalidArgumentError({
|
|
537
|
+
message: `Invalid path parameter '${placeholder}': ${problem}`,
|
|
538
|
+
service,
|
|
539
|
+
endpoint: pathTemplate
|
|
540
|
+
});
|
|
541
|
+
}
|
|
449
542
|
};
|
|
450
543
|
|
|
451
544
|
// src/services/agr-info/generated/schemas.ts
|
|
@@ -453,8 +546,10 @@ import * as v2 from "valibot";
|
|
|
453
546
|
|
|
454
547
|
// src/core/schemas.ts
|
|
455
548
|
import * as v from "valibot";
|
|
549
|
+
var nodeEnv = () => typeof process === "undefined" ? void 0 : process.env?.NODE_ENV;
|
|
456
550
|
var logNormalizationWarning = (message) => {
|
|
457
|
-
|
|
551
|
+
const env = nodeEnv();
|
|
552
|
+
if (env !== void 0 && env !== "production") {
|
|
458
553
|
console.warn(`[augur-api] Response normalization: ${message}`);
|
|
459
554
|
}
|
|
460
555
|
};
|
|
@@ -3697,6 +3792,7 @@ var CategoriesListDataSchema = v7.array(
|
|
|
3697
3792
|
focusCd: v7.number()
|
|
3698
3793
|
})
|
|
3699
3794
|
);
|
|
3795
|
+
var CategoriesFocusCreateDataSchema = v7.boolean();
|
|
3700
3796
|
var CategoriesGetDataSchema = v7.looseObject({
|
|
3701
3797
|
itemCategoryUid: v7.number(),
|
|
3702
3798
|
itemCategoryId: v7.string(),
|
|
@@ -3747,8 +3843,8 @@ var endpoints7 = [
|
|
|
3747
3843
|
pathParams: [],
|
|
3748
3844
|
queryParams: [],
|
|
3749
3845
|
edgeCache: false,
|
|
3750
|
-
responseSchema:
|
|
3751
|
-
responseType: "
|
|
3846
|
+
responseSchema: CategoriesFocusCreateDataSchema,
|
|
3847
|
+
responseType: "scalar"
|
|
3752
3848
|
},
|
|
3753
3849
|
{
|
|
3754
3850
|
method: "GET",
|
|
@@ -8621,6 +8717,7 @@ var ItemSearchListParamsSchema = v15.looseObject({
|
|
|
8621
8717
|
sourceFieldsList: v15.optional(v15.string()),
|
|
8622
8718
|
stockStatus: v15.optional(v15.string()),
|
|
8623
8719
|
tags: v15.optional(v15.string()),
|
|
8720
|
+
useBrandFolderDoc: v15.optional(v15.string()),
|
|
8624
8721
|
variantFilter: v15.optional(v15.string())
|
|
8625
8722
|
});
|
|
8626
8723
|
var ItemSearchFacetsListParamsSchema = v15.looseObject({
|
|
@@ -8647,11 +8744,16 @@ var ItemSearchFacetsListParamsSchema = v15.looseObject({
|
|
|
8647
8744
|
});
|
|
8648
8745
|
var ItemSearchAttributesListParamsSchema = v15.looseObject({
|
|
8649
8746
|
...EdgeCacheParamsSchema.entries,
|
|
8650
|
-
|
|
8651
|
-
|
|
8747
|
+
classId5List: v15.optional(v15.string()),
|
|
8748
|
+
fields: v15.optional(v15.string()),
|
|
8652
8749
|
filters: v15.optional(v15.string()),
|
|
8750
|
+
from: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
8751
|
+
operator: v15.optional(v15.string()),
|
|
8653
8752
|
q: v15.string(),
|
|
8654
|
-
searchType: v15.string()
|
|
8753
|
+
searchType: v15.string(),
|
|
8754
|
+
size: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
8755
|
+
sort: v15.optional(v15.string()),
|
|
8756
|
+
sourceFieldsList: v15.optional(v15.string())
|
|
8655
8757
|
});
|
|
8656
8758
|
var ItemsListParamsSchema = v15.looseObject({
|
|
8657
8759
|
...EdgeCacheParamsSchema.entries,
|
|
@@ -8659,6 +8761,7 @@ var ItemsListParamsSchema = v15.looseObject({
|
|
|
8659
8761
|
limit: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
8660
8762
|
offset: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
8661
8763
|
online: v15.optional(v15.string()),
|
|
8764
|
+
orderBy: v15.optional(v15.string()),
|
|
8662
8765
|
statusCd: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number)))
|
|
8663
8766
|
});
|
|
8664
8767
|
var QueryStringRedirectListParamsSchema = v15.looseObject({
|
|
@@ -8683,6 +8786,69 @@ var SuggestionsSuggestListParamsSchema = v15.looseObject({
|
|
|
8683
8786
|
offset: v15.optional(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
8684
8787
|
q: v15.optional(v15.string())
|
|
8685
8788
|
});
|
|
8789
|
+
var ItemSearchAttributesListDataSchema = v15.looseObject({
|
|
8790
|
+
attributes: v15.array(
|
|
8791
|
+
v15.looseObject({
|
|
8792
|
+
attributeUid: v15.number(),
|
|
8793
|
+
attributeId: v15.string(),
|
|
8794
|
+
attributeDesc: v15.nullable(v15.string()),
|
|
8795
|
+
sequenceNo: v15.nullable(v15.number()),
|
|
8796
|
+
values: v15.array(
|
|
8797
|
+
v15.looseObject({
|
|
8798
|
+
attributeValueUid: v15.number(),
|
|
8799
|
+
attributeValue: v15.string(),
|
|
8800
|
+
sequenceNo: v15.number()
|
|
8801
|
+
})
|
|
8802
|
+
),
|
|
8803
|
+
valueCount: v15.number()
|
|
8804
|
+
})
|
|
8805
|
+
)
|
|
8806
|
+
});
|
|
8807
|
+
var ItemsListDataSchema = v15.array(
|
|
8808
|
+
v15.looseObject({
|
|
8809
|
+
invMastUid: v15.number(),
|
|
8810
|
+
itemId: v15.nullable(v15.string()),
|
|
8811
|
+
online: v15.string(),
|
|
8812
|
+
updateCd: v15.number(),
|
|
8813
|
+
doc: v15.nullable(v15.string()),
|
|
8814
|
+
indexCd: v15.number(),
|
|
8815
|
+
statusCd: v15.number(),
|
|
8816
|
+
processCd: v15.number(),
|
|
8817
|
+
indexStatusCd: v15.number(),
|
|
8818
|
+
dateCreated: v15.string(),
|
|
8819
|
+
dateLastModified: v15.string(),
|
|
8820
|
+
classId5: v15.nullable(v15.string()),
|
|
8821
|
+
dateLastChecked: v15.string(),
|
|
8822
|
+
embeddingCd: v15.number(),
|
|
8823
|
+
docHash: v15.nullable(v15.string()),
|
|
8824
|
+
indexHash: v15.nullable(v15.string()),
|
|
8825
|
+
location: v15.nullable(v15.string()),
|
|
8826
|
+
uuid: v15.nullable(v15.string())
|
|
8827
|
+
})
|
|
8828
|
+
);
|
|
8829
|
+
var ItemsRefreshUpdateDataSchema = v15.boolean();
|
|
8830
|
+
var ItemsGetDataSchema = v15.looseObject({
|
|
8831
|
+
invMastUid: v15.number(),
|
|
8832
|
+
itemId: v15.nullable(v15.string()),
|
|
8833
|
+
online: v15.string(),
|
|
8834
|
+
updateCd: v15.number(),
|
|
8835
|
+
doc: v15.nullable(v15.string()),
|
|
8836
|
+
indexCd: v15.number(),
|
|
8837
|
+
statusCd: v15.number(),
|
|
8838
|
+
processCd: v15.number(),
|
|
8839
|
+
indexStatusCd: v15.number(),
|
|
8840
|
+
dateCreated: v15.string(),
|
|
8841
|
+
dateLastModified: v15.string(),
|
|
8842
|
+
classId5: v15.nullable(v15.string()),
|
|
8843
|
+
dateLastChecked: v15.string(),
|
|
8844
|
+
embeddingCd: v15.number(),
|
|
8845
|
+
docHash: v15.nullable(v15.string()),
|
|
8846
|
+
indexHash: v15.nullable(v15.string()),
|
|
8847
|
+
location: v15.nullable(v15.string()),
|
|
8848
|
+
uuid: v15.nullable(v15.string())
|
|
8849
|
+
});
|
|
8850
|
+
var ItemsUpdateDataSchema = ItemsGetDataSchema;
|
|
8851
|
+
var ItemsRefreshGetDataSchema = ItemsGetDataSchema;
|
|
8686
8852
|
var QueryStringRedirectListDataSchema = v15.array(
|
|
8687
8853
|
v15.looseObject({
|
|
8688
8854
|
queryStringRedirectUid: v15.number(),
|
|
@@ -8724,6 +8890,21 @@ var SuggestionsListDataSchema = v15.array(
|
|
|
8724
8890
|
processCd: v15.number()
|
|
8725
8891
|
})
|
|
8726
8892
|
);
|
|
8893
|
+
var SuggestionsSuggestListDataSchema = v15.array(
|
|
8894
|
+
v15.looseObject({
|
|
8895
|
+
suggestionsUid: v15.number(),
|
|
8896
|
+
queryStringUid: v15.number(),
|
|
8897
|
+
suggestionsString: v15.string(),
|
|
8898
|
+
suggestionsMetaphone: v15.nullable(v15.string()),
|
|
8899
|
+
avgTotalResults: v15.number(),
|
|
8900
|
+
dateCreated: v15.string(),
|
|
8901
|
+
dateLastModified: v15.string(),
|
|
8902
|
+
updateCd: v15.number(),
|
|
8903
|
+
statusCd: v15.number(),
|
|
8904
|
+
processCd: v15.number(),
|
|
8905
|
+
score: v15.number()
|
|
8906
|
+
})
|
|
8907
|
+
);
|
|
8727
8908
|
var SuggestionsGetDataSchema = v15.looseObject({
|
|
8728
8909
|
suggestionsUid: v15.number(),
|
|
8729
8910
|
queryStringUid: v15.number(),
|
|
@@ -8765,6 +8946,7 @@ var endpoints15 = [
|
|
|
8765
8946
|
"sourceFieldsList",
|
|
8766
8947
|
"stockStatus",
|
|
8767
8948
|
"tags",
|
|
8949
|
+
"useBrandFolderDoc",
|
|
8768
8950
|
"variantFilter"
|
|
8769
8951
|
],
|
|
8770
8952
|
edgeCache: true,
|
|
@@ -8810,10 +8992,21 @@ var endpoints15 = [
|
|
|
8810
8992
|
action: "list",
|
|
8811
8993
|
aliases: [],
|
|
8812
8994
|
pathParams: [],
|
|
8813
|
-
queryParams: [
|
|
8995
|
+
queryParams: [
|
|
8996
|
+
"classId5List",
|
|
8997
|
+
"fields",
|
|
8998
|
+
"filters",
|
|
8999
|
+
"from",
|
|
9000
|
+
"operator",
|
|
9001
|
+
"q",
|
|
9002
|
+
"searchType",
|
|
9003
|
+
"size",
|
|
9004
|
+
"sort",
|
|
9005
|
+
"sourceFieldsList"
|
|
9006
|
+
],
|
|
8814
9007
|
edgeCache: true,
|
|
8815
|
-
responseSchema:
|
|
8816
|
-
responseType: "
|
|
9008
|
+
responseSchema: ItemSearchAttributesListDataSchema,
|
|
9009
|
+
responseType: "object"
|
|
8817
9010
|
},
|
|
8818
9011
|
{
|
|
8819
9012
|
method: "GET",
|
|
@@ -8822,10 +9015,10 @@ var endpoints15 = [
|
|
|
8822
9015
|
action: "list",
|
|
8823
9016
|
aliases: [],
|
|
8824
9017
|
pathParams: [],
|
|
8825
|
-
queryParams: ["itemId", "limit", "offset", "online", "statusCd"],
|
|
9018
|
+
queryParams: ["itemId", "limit", "offset", "online", "orderBy", "statusCd"],
|
|
8826
9019
|
edgeCache: true,
|
|
8827
|
-
responseSchema:
|
|
8828
|
-
responseType: "
|
|
9020
|
+
responseSchema: ItemsListDataSchema,
|
|
9021
|
+
responseType: "array"
|
|
8829
9022
|
},
|
|
8830
9023
|
{
|
|
8831
9024
|
method: "PUT",
|
|
@@ -8836,8 +9029,8 @@ var endpoints15 = [
|
|
|
8836
9029
|
pathParams: [],
|
|
8837
9030
|
queryParams: [],
|
|
8838
9031
|
edgeCache: false,
|
|
8839
|
-
responseSchema:
|
|
8840
|
-
responseType: "
|
|
9032
|
+
responseSchema: ItemsRefreshUpdateDataSchema,
|
|
9033
|
+
responseType: "scalar"
|
|
8841
9034
|
},
|
|
8842
9035
|
{
|
|
8843
9036
|
method: "GET",
|
|
@@ -8848,8 +9041,8 @@ var endpoints15 = [
|
|
|
8848
9041
|
pathParams: ["invMastUid"],
|
|
8849
9042
|
queryParams: [],
|
|
8850
9043
|
edgeCache: true,
|
|
8851
|
-
responseSchema:
|
|
8852
|
-
responseType: "
|
|
9044
|
+
responseSchema: ItemsGetDataSchema,
|
|
9045
|
+
responseType: "object"
|
|
8853
9046
|
},
|
|
8854
9047
|
{
|
|
8855
9048
|
method: "PUT",
|
|
@@ -8860,8 +9053,8 @@ var endpoints15 = [
|
|
|
8860
9053
|
pathParams: ["invMastUid"],
|
|
8861
9054
|
queryParams: [],
|
|
8862
9055
|
edgeCache: false,
|
|
8863
|
-
responseSchema:
|
|
8864
|
-
responseType: "
|
|
9056
|
+
responseSchema: ItemsUpdateDataSchema,
|
|
9057
|
+
responseType: "object"
|
|
8865
9058
|
},
|
|
8866
9059
|
{
|
|
8867
9060
|
method: "GET",
|
|
@@ -8872,8 +9065,8 @@ var endpoints15 = [
|
|
|
8872
9065
|
pathParams: ["invMastUid"],
|
|
8873
9066
|
queryParams: [],
|
|
8874
9067
|
edgeCache: true,
|
|
8875
|
-
responseSchema:
|
|
8876
|
-
responseType: "
|
|
9068
|
+
responseSchema: ItemsRefreshGetDataSchema,
|
|
9069
|
+
responseType: "object"
|
|
8877
9070
|
},
|
|
8878
9071
|
{
|
|
8879
9072
|
method: "GET",
|
|
@@ -8956,8 +9149,8 @@ var endpoints15 = [
|
|
|
8956
9149
|
pathParams: [],
|
|
8957
9150
|
queryParams: ["limit", "offset", "q"],
|
|
8958
9151
|
edgeCache: true,
|
|
8959
|
-
responseSchema:
|
|
8960
|
-
responseType: "
|
|
9152
|
+
responseSchema: SuggestionsSuggestListDataSchema,
|
|
9153
|
+
responseType: "array"
|
|
8961
9154
|
},
|
|
8962
9155
|
{
|
|
8963
9156
|
method: "GET",
|
|
@@ -13567,52 +13760,100 @@ function registryEntries() {
|
|
|
13567
13760
|
cache ?? (cache = build());
|
|
13568
13761
|
return [...cache];
|
|
13569
13762
|
}
|
|
13763
|
+
var index;
|
|
13764
|
+
function buildIndex() {
|
|
13765
|
+
const map = /* @__PURE__ */ new Map();
|
|
13766
|
+
for (const entry of registryEntries()) {
|
|
13767
|
+
map.set(entry.id, entry);
|
|
13768
|
+
const chain = entry.id.slice(0, entry.id.lastIndexOf("."));
|
|
13769
|
+
for (const alias of entry.aliases) {
|
|
13770
|
+
map.set(`${chain}.${alias}`, entry);
|
|
13771
|
+
}
|
|
13772
|
+
}
|
|
13773
|
+
return map;
|
|
13774
|
+
}
|
|
13775
|
+
function resolveEndpoint(id) {
|
|
13776
|
+
index ?? (index = buildIndex());
|
|
13777
|
+
return index.get(id);
|
|
13778
|
+
}
|
|
13779
|
+
|
|
13780
|
+
// src/core/call.ts
|
|
13781
|
+
var ENVELOPE_KEYS = [
|
|
13782
|
+
"count",
|
|
13783
|
+
"data",
|
|
13784
|
+
"message",
|
|
13785
|
+
"options",
|
|
13786
|
+
"params",
|
|
13787
|
+
"status",
|
|
13788
|
+
"total",
|
|
13789
|
+
"totalResults"
|
|
13790
|
+
];
|
|
13791
|
+
var EDGE_CACHE_KEY = "edgeCache";
|
|
13792
|
+
function invalid(message, entry) {
|
|
13793
|
+
return new InvalidArgumentError({
|
|
13794
|
+
message,
|
|
13795
|
+
service: entry?.service ?? "",
|
|
13796
|
+
endpoint: entry?.path ?? ""
|
|
13797
|
+
});
|
|
13798
|
+
}
|
|
13799
|
+
function rejectUnknown(entry, kind, keys, allowed) {
|
|
13800
|
+
const unknown28 = keys.filter((key) => !allowed.includes(key));
|
|
13801
|
+
if (unknown28.length > 0) {
|
|
13802
|
+
throw invalid(`Unknown ${kind} for ${entry.id}: ${unknown28.join(", ")}`, entry);
|
|
13803
|
+
}
|
|
13804
|
+
}
|
|
13805
|
+
function checkArgs(entry, args) {
|
|
13806
|
+
const pathKeys = Object.keys(args.pathParams ?? {});
|
|
13807
|
+
const missing = entry.pathParams.filter((name) => !pathKeys.includes(name));
|
|
13808
|
+
if (missing.length > 0) {
|
|
13809
|
+
throw invalid(`Missing path params for ${entry.id}: ${missing.join(", ")}`, entry);
|
|
13810
|
+
}
|
|
13811
|
+
rejectUnknown(entry, "path params", pathKeys, entry.pathParams);
|
|
13812
|
+
const queryAllowed = entry.edgeCache ? [...entry.queryParams, EDGE_CACHE_KEY] : entry.queryParams;
|
|
13813
|
+
rejectUnknown(entry, "query params", Object.keys(args.query ?? {}), queryAllowed);
|
|
13814
|
+
if (args.body !== void 0 && args.body !== null && !entry.hasBody) {
|
|
13815
|
+
throw invalid(`${entry.id} takes no body`, entry);
|
|
13816
|
+
}
|
|
13817
|
+
}
|
|
13818
|
+
function fillPath(entry, pathParams) {
|
|
13819
|
+
return entry.path.replace(/\{([^}]+)\}/g, (_, name) => {
|
|
13820
|
+
const value = String(pathParams[name]);
|
|
13821
|
+
validatePathSegment(entry.path, name, value, entry.service);
|
|
13822
|
+
return value;
|
|
13823
|
+
});
|
|
13824
|
+
}
|
|
13825
|
+
function toEnvelope(body) {
|
|
13826
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) {
|
|
13827
|
+
return null;
|
|
13828
|
+
}
|
|
13829
|
+
const record27 = body;
|
|
13830
|
+
if (!ENVELOPE_KEYS.every((key) => key in record27)) {
|
|
13831
|
+
return null;
|
|
13832
|
+
}
|
|
13833
|
+
return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record27[key]]));
|
|
13834
|
+
}
|
|
13835
|
+
async function callEndpoint(config, id, args = {}) {
|
|
13836
|
+
const entry = resolveEndpoint(id);
|
|
13837
|
+
if (!entry) {
|
|
13838
|
+
throw invalid(`Unknown endpoint id: ${id}`);
|
|
13839
|
+
}
|
|
13840
|
+
checkArgs(entry, args);
|
|
13841
|
+
const url = `https://${entry.service}.augur-api.com${fillPath(entry, args.pathParams ?? {})}`;
|
|
13842
|
+
const raw = await new HTTPClient(entry.service, config).raw(entry.method, url, {
|
|
13843
|
+
params: args.query,
|
|
13844
|
+
data: args.body ?? void 0,
|
|
13845
|
+
config: { endpoint: entry.path }
|
|
13846
|
+
});
|
|
13847
|
+
const parsed = parseJson(raw.text);
|
|
13848
|
+
const body = parsed.json ? parsed.value : raw.text;
|
|
13849
|
+
return { httpStatus: raw.status, envelope: toEnvelope(body), body };
|
|
13850
|
+
}
|
|
13570
13851
|
|
|
13571
13852
|
// src/core/common-schemas.ts
|
|
13572
13853
|
var CommonHealthCheckResponseSchema = BaseResponseSchema(HealthCheckDataSchema);
|
|
13573
13854
|
var CommonPingResponseSchema = BaseResponseSchema(PingDataSchema);
|
|
13574
13855
|
var CommonWhoamiResponseSchema = BaseResponseSchema(WhoamiDataSchema);
|
|
13575
13856
|
|
|
13576
|
-
// src/core/path-validation.ts
|
|
13577
|
-
var normalise = (name) => name.replace(/[-_]/g, "").toLowerCase();
|
|
13578
|
-
var NUMERIC_EXACT = /* @__PURE__ */ new Set(["id", "linenumber"]);
|
|
13579
|
-
var NUMERIC_SUFFIX_RE = /(?:id|uid|no|num|number)$/;
|
|
13580
|
-
var STRING_OVERRIDES = /* @__PURE__ */ new Set([
|
|
13581
|
-
"siteid",
|
|
13582
|
-
"pono",
|
|
13583
|
-
"importuid",
|
|
13584
|
-
"scheduledimportmasteruid",
|
|
13585
|
-
"grantid",
|
|
13586
|
-
"salesrepid"
|
|
13587
|
-
]);
|
|
13588
|
-
var isNumericPlaceholder = (placeholder) => {
|
|
13589
|
-
const normalised = normalise(placeholder);
|
|
13590
|
-
if (STRING_OVERRIDES.has(normalised)) return false;
|
|
13591
|
-
if (NUMERIC_EXACT.has(normalised)) return true;
|
|
13592
|
-
return NUMERIC_SUFFIX_RE.test(normalised);
|
|
13593
|
-
};
|
|
13594
|
-
var INTEGER_RE = /^-?\d+$/;
|
|
13595
|
-
var validatePathSegment = (pathTemplate, placeholder, value) => {
|
|
13596
|
-
const isNumeric = isNumericPlaceholder(placeholder);
|
|
13597
|
-
if (isNumeric) {
|
|
13598
|
-
if (!INTEGER_RE.test(value)) {
|
|
13599
|
-
throw new InvalidArgumentError({
|
|
13600
|
-
message: `Invalid path parameter '${placeholder}': expected an integer, received ${JSON.stringify(value)}`,
|
|
13601
|
-
service: "http-client",
|
|
13602
|
-
endpoint: pathTemplate
|
|
13603
|
-
});
|
|
13604
|
-
}
|
|
13605
|
-
return;
|
|
13606
|
-
}
|
|
13607
|
-
if (value === "") {
|
|
13608
|
-
throw new InvalidArgumentError({
|
|
13609
|
-
message: `Invalid path parameter '${placeholder}': expected a non-empty string, received ${JSON.stringify(value)}`,
|
|
13610
|
-
service: "http-client",
|
|
13611
|
-
endpoint: pathTemplate
|
|
13612
|
-
});
|
|
13613
|
-
}
|
|
13614
|
-
};
|
|
13615
|
-
|
|
13616
13857
|
// src/core/base-client.ts
|
|
13617
13858
|
import * as v27 from "valibot";
|
|
13618
13859
|
function toDiscoveryEndpoint(entry) {
|
|
@@ -13692,7 +13933,7 @@ var BaseServiceClient = class {
|
|
|
13692
13933
|
return validatedResponse;
|
|
13693
13934
|
} catch (error) {
|
|
13694
13935
|
if (error instanceof v27.ValiError) {
|
|
13695
|
-
throw this.createValidationError(error, config,
|
|
13936
|
+
throw this.createValidationError(error, config, "response");
|
|
13696
13937
|
}
|
|
13697
13938
|
throw error;
|
|
13698
13939
|
}
|
|
@@ -13712,7 +13953,7 @@ var BaseServiceClient = class {
|
|
|
13712
13953
|
return v27.parse(config.paramsSchema, params ?? {});
|
|
13713
13954
|
} catch (error) {
|
|
13714
13955
|
if (error instanceof v27.ValiError) {
|
|
13715
|
-
throw this.createValidationError(error, config,
|
|
13956
|
+
throw this.createValidationError(error, config, "params");
|
|
13716
13957
|
}
|
|
13717
13958
|
throw error;
|
|
13718
13959
|
}
|
|
@@ -13729,48 +13970,33 @@ var BaseServiceClient = class {
|
|
|
13729
13970
|
*/
|
|
13730
13971
|
async executeHttpRequest(config, endpoint, validatedParams, query) {
|
|
13731
13972
|
const url = `${this.baseUrl}${endpoint}`;
|
|
13732
|
-
const
|
|
13973
|
+
const requestConfig = { endpoint: config.path };
|
|
13733
13974
|
switch (config.method) {
|
|
13734
13975
|
case "GET":
|
|
13735
|
-
return await this.http.get(url, validatedParams);
|
|
13976
|
+
return await this.http.get(url, validatedParams, requestConfig);
|
|
13736
13977
|
case "POST":
|
|
13737
|
-
return await this.http.post(url, validatedParams,
|
|
13978
|
+
return await this.http.post(url, validatedParams, query, requestConfig);
|
|
13738
13979
|
case "PUT":
|
|
13739
|
-
return await this.http.put(url, validatedParams,
|
|
13980
|
+
return await this.http.put(url, validatedParams, query, requestConfig);
|
|
13740
13981
|
case "DELETE":
|
|
13741
|
-
return await this.http.delete(url,
|
|
13982
|
+
return await this.http.delete(url, query, requestConfig);
|
|
13742
13983
|
default:
|
|
13743
13984
|
throw new Error(`Unsupported HTTP method: ${config.method}`);
|
|
13744
13985
|
}
|
|
13745
13986
|
}
|
|
13746
13987
|
/**
|
|
13747
|
-
* Create a
|
|
13988
|
+
* Create a validation error for invalid params or an unexpected response.
|
|
13989
|
+
*
|
|
13990
|
+
* @ensures result.endpoint = config.path (the template; the filled path can hold param values)
|
|
13991
|
+
* @ensures result.message holds no param values (issues name fields; valibot issue messages
|
|
13992
|
+
* describe the expected type, and `received` is not copied)
|
|
13748
13993
|
*/
|
|
13749
|
-
createValidationError(valibotError, config,
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
if (errorType === "params") {
|
|
13753
|
-
message = "Invalid request parameters";
|
|
13754
|
-
contextInfo = `
|
|
13755
|
-
Provided parameters: ${JSON.stringify(params, null, 2)}`;
|
|
13756
|
-
} else if (errorType === "response") {
|
|
13757
|
-
message = "Invalid API response structure";
|
|
13758
|
-
contextInfo = "\nThis appears to be a response validation error. The API returned data in an unexpected format during API refactoring.";
|
|
13759
|
-
} else {
|
|
13760
|
-
const hasParamSchema = !!config.paramsSchema;
|
|
13761
|
-
if (hasParamSchema && params !== void 0) {
|
|
13762
|
-
message = "Invalid request parameters";
|
|
13763
|
-
contextInfo = `
|
|
13764
|
-
Provided parameters: ${JSON.stringify(params, null, 2)}`;
|
|
13765
|
-
} else if (!hasParamSchema) {
|
|
13766
|
-
message = "Invalid API response structure";
|
|
13767
|
-
contextInfo = "\nThis appears to be a response validation error. The API returned data in an unexpected format.";
|
|
13768
|
-
}
|
|
13769
|
-
}
|
|
13770
|
-
const validationError = new ValidationError({
|
|
13994
|
+
createValidationError(valibotError, config, errorType) {
|
|
13995
|
+
const message = errorType === "params" ? "Invalid request parameters" : "Invalid API response structure\nThis appears to be a response validation error. The API returned data in an unexpected format.";
|
|
13996
|
+
return new ValidationError({
|
|
13771
13997
|
message,
|
|
13772
13998
|
service: this.serviceName,
|
|
13773
|
-
endpoint,
|
|
13999
|
+
endpoint: config.path,
|
|
13774
14000
|
validationErrors: valibotError.issues.map((issue) => ({
|
|
13775
14001
|
path: (issue.path ?? []).map((segment) => segment.key),
|
|
13776
14002
|
message: issue.message,
|
|
@@ -13778,10 +14004,6 @@ Provided parameters: ${JSON.stringify(params, null, 2)}`;
|
|
|
13778
14004
|
code: issue.type ?? "unknown"
|
|
13779
14005
|
}))
|
|
13780
14006
|
});
|
|
13781
|
-
if (contextInfo) {
|
|
13782
|
-
validationError.message += contextInfo;
|
|
13783
|
-
}
|
|
13784
|
-
return validationError;
|
|
13785
14007
|
}
|
|
13786
14008
|
/**
|
|
13787
14009
|
* Build endpoint path with optional path parameter substitution
|
|
@@ -13805,13 +14027,13 @@ Provided parameters: ${JSON.stringify(params, null, 2)}`;
|
|
|
13805
14027
|
for (const [key, value] of Object.entries(pathParams)) {
|
|
13806
14028
|
const stringValue = String(value);
|
|
13807
14029
|
if (path.includes(`{${key}}`)) {
|
|
13808
|
-
validatePathSegment(pathTemplate, key, stringValue);
|
|
14030
|
+
validatePathSegment(pathTemplate, key, stringValue, this.serviceName);
|
|
13809
14031
|
path = path.replace(`{${key}}`, stringValue);
|
|
13810
14032
|
} else {
|
|
13811
14033
|
const normKey = normalise2(key);
|
|
13812
14034
|
path = path.replace(/\{([^}]+)\}/g, (match, placeholder) => {
|
|
13813
14035
|
if (normalise2(placeholder) === normKey) {
|
|
13814
|
-
validatePathSegment(pathTemplate, placeholder, stringValue);
|
|
14036
|
+
validatePathSegment(pathTemplate, placeholder, stringValue, this.serviceName);
|
|
13815
14037
|
return stringValue;
|
|
13816
14038
|
}
|
|
13817
14039
|
return match;
|
|
@@ -13892,15 +14114,15 @@ function createNodeObject(serviceName, executeRequest, node) {
|
|
|
13892
14114
|
}
|
|
13893
14115
|
function splitPathArgs(pathParams, args) {
|
|
13894
14116
|
const pathParamMap = {};
|
|
13895
|
-
let
|
|
14117
|
+
let index2 = 0;
|
|
13896
14118
|
for (const name of pathParams) {
|
|
13897
|
-
if (
|
|
14119
|
+
if (index2 >= args.length) {
|
|
13898
14120
|
break;
|
|
13899
14121
|
}
|
|
13900
|
-
pathParamMap[name] = String(args[
|
|
13901
|
-
|
|
14122
|
+
pathParamMap[name] = String(args[index2]);
|
|
14123
|
+
index2++;
|
|
13902
14124
|
}
|
|
13903
|
-
return { pathParamMap, rest: args.slice(
|
|
14125
|
+
return { pathParamMap, rest: args.slice(index2) };
|
|
13904
14126
|
}
|
|
13905
14127
|
function splitBodyAndQuery(method, rest) {
|
|
13906
14128
|
if (method === "POST" || method === "PUT") {
|
|
@@ -14681,6 +14903,22 @@ var _AugurAPI = class _AugurAPI {
|
|
|
14681
14903
|
static endpoints() {
|
|
14682
14904
|
return registryEntries();
|
|
14683
14905
|
}
|
|
14906
|
+
/**
|
|
14907
|
+
* Call any endpoint by registry id (canonical or alias), with no typed method.
|
|
14908
|
+
*
|
|
14909
|
+
* Arguments are checked against the entry before any request is sent. A 2xx
|
|
14910
|
+
* always resolves, with no schema validation; other statuses throw the same
|
|
14911
|
+
* errors as the typed methods.
|
|
14912
|
+
*
|
|
14913
|
+
* @example
|
|
14914
|
+
* ```typescript
|
|
14915
|
+
* const result = await api.call('items.invMast.doc.get', { pathParams: { invMastUid: 123 } });
|
|
14916
|
+
* result.envelope?.data;
|
|
14917
|
+
* ```
|
|
14918
|
+
*/
|
|
14919
|
+
call(id, args) {
|
|
14920
|
+
return callEndpoint(this.config, id, args);
|
|
14921
|
+
}
|
|
14684
14922
|
/**
|
|
14685
14923
|
* Create AugurAPI client from context object
|
|
14686
14924
|
*
|
|
@@ -15552,7 +15790,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
|
|
|
15552
15790
|
}
|
|
15553
15791
|
|
|
15554
15792
|
// src/index.ts
|
|
15555
|
-
var VERSION = "2026.9.
|
|
15793
|
+
var VERSION = "2026.9.7";
|
|
15556
15794
|
export {
|
|
15557
15795
|
AgrInfoClient,
|
|
15558
15796
|
AgrIntClient,
|