deere-sdk 1.0.10 → 2.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 +223 -0
- package/README.md +130 -20
- package/dist/api/aemp.d.ts +4 -0
- package/dist/api/aemp.d.ts.map +1 -1
- package/dist/api/aemp.js +5 -1
- package/dist/api/aemp.js.map +1 -1
- package/dist/api/assets.d.ts +4 -0
- package/dist/api/assets.d.ts.map +1 -1
- package/dist/api/assets.js +13 -9
- package/dist/api/assets.js.map +1 -1
- package/dist/api/boundaries.d.ts +4 -0
- package/dist/api/boundaries.d.ts.map +1 -1
- package/dist/api/boundaries.js +12 -8
- package/dist/api/boundaries.js.map +1 -1
- package/dist/api/clients.d.ts +4 -0
- package/dist/api/clients.d.ts.map +1 -1
- package/dist/api/clients.js +12 -8
- package/dist/api/clients.js.map +1 -1
- package/dist/api/connection-management.d.ts +4 -0
- package/dist/api/connection-management.d.ts.map +1 -1
- package/dist/api/connection-management.js +8 -4
- package/dist/api/connection-management.js.map +1 -1
- package/dist/api/crop-types.d.ts +4 -0
- package/dist/api/crop-types.d.ts.map +1 -1
- package/dist/api/crop-types.js +9 -5
- package/dist/api/crop-types.js.map +1 -1
- package/dist/api/equipment-measurement.d.ts +4 -0
- package/dist/api/equipment-measurement.d.ts.map +1 -1
- package/dist/api/equipment-measurement.js +5 -1
- package/dist/api/equipment-measurement.js.map +1 -1
- package/dist/api/equipment.d.ts +4 -0
- package/dist/api/equipment.d.ts.map +1 -1
- package/dist/api/equipment.js +20 -16
- package/dist/api/equipment.js.map +1 -1
- package/dist/api/farms.d.ts +4 -0
- package/dist/api/farms.d.ts.map +1 -1
- package/dist/api/farms.js +12 -8
- package/dist/api/farms.js.map +1 -1
- package/dist/api/field-operations-api.d.ts +4 -0
- package/dist/api/field-operations-api.d.ts.map +1 -1
- package/dist/api/field-operations-api.js +8 -4
- package/dist/api/field-operations-api.js.map +1 -1
- package/dist/api/fields.d.ts +4 -0
- package/dist/api/fields.d.ts.map +1 -1
- package/dist/api/fields.js +12 -8
- package/dist/api/fields.js.map +1 -1
- package/dist/api/files.d.ts +4 -0
- package/dist/api/files.d.ts.map +1 -1
- package/dist/api/files.js +10 -6
- package/dist/api/files.js.map +1 -1
- package/dist/api/flags.d.ts +4 -0
- package/dist/api/flags.d.ts.map +1 -1
- package/dist/api/flags.js +11 -7
- package/dist/api/flags.js.map +1 -1
- package/dist/api/guidance-lines.d.ts +4 -0
- package/dist/api/guidance-lines.d.ts.map +1 -1
- package/dist/api/guidance-lines.js +9 -5
- package/dist/api/guidance-lines.js.map +1 -1
- package/dist/api/harvest-id.d.ts +4 -0
- package/dist/api/harvest-id.d.ts.map +1 -1
- package/dist/api/harvest-id.js +7 -3
- package/dist/api/harvest-id.js.map +1 -1
- package/dist/api/machine-alerts.d.ts +4 -0
- package/dist/api/machine-alerts.d.ts.map +1 -1
- package/dist/api/machine-alerts.js +6 -2
- package/dist/api/machine-alerts.js.map +1 -1
- package/dist/api/machine-device-state-reports.d.ts +4 -0
- package/dist/api/machine-device-state-reports.d.ts.map +1 -1
- package/dist/api/machine-device-state-reports.js +5 -1
- package/dist/api/machine-device-state-reports.js.map +1 -1
- package/dist/api/machine-engine-hours.d.ts +4 -0
- package/dist/api/machine-engine-hours.d.ts.map +1 -1
- package/dist/api/machine-engine-hours.js +6 -2
- package/dist/api/machine-engine-hours.js.map +1 -1
- package/dist/api/machine-hours-of-operation.d.ts +4 -0
- package/dist/api/machine-hours-of-operation.d.ts.map +1 -1
- package/dist/api/machine-hours-of-operation.js +6 -2
- package/dist/api/machine-hours-of-operation.js.map +1 -1
- package/dist/api/machine-locations.d.ts +4 -0
- package/dist/api/machine-locations.d.ts.map +1 -1
- package/dist/api/machine-locations.js +5 -1
- package/dist/api/machine-locations.js.map +1 -1
- package/dist/api/map-layers.d.ts +4 -0
- package/dist/api/map-layers.d.ts.map +1 -1
- package/dist/api/map-layers.js +9 -5
- package/dist/api/map-layers.js.map +1 -1
- package/dist/api/notifications.d.ts +4 -0
- package/dist/api/notifications.d.ts.map +1 -1
- package/dist/api/notifications.js +9 -5
- package/dist/api/notifications.js.map +1 -1
- package/dist/api/operators.d.ts +4 -0
- package/dist/api/operators.d.ts.map +1 -1
- package/dist/api/operators.js +11 -7
- package/dist/api/operators.js.map +1 -1
- package/dist/api/organizations.d.ts +4 -0
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +9 -5
- package/dist/api/organizations.js.map +1 -1
- package/dist/api/partnerships.d.ts +4 -0
- package/dist/api/partnerships.d.ts.map +1 -1
- package/dist/api/partnerships.js +11 -7
- package/dist/api/partnerships.js.map +1 -1
- package/dist/api/products.d.ts +4 -0
- package/dist/api/products.d.ts.map +1 -1
- package/dist/api/products.js +14 -10
- package/dist/api/products.js.map +1 -1
- package/dist/api/users.d.ts +4 -0
- package/dist/api/users.d.ts.map +1 -1
- package/dist/api/users.js +5 -1
- package/dist/api/users.js.map +1 -1
- package/dist/api/webhook.d.ts +4 -0
- package/dist/api/webhook.d.ts.map +1 -1
- package/dist/api/webhook.js +9 -5
- package/dist/api/webhook.js.map +1 -1
- package/dist/api-servers.generated.d.ts +72 -0
- package/dist/api-servers.generated.d.ts.map +1 -0
- package/dist/api-servers.generated.js +344 -0
- package/dist/api-servers.generated.js.map +1 -0
- package/dist/client.d.ts +95 -47
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +196 -105
- package/dist/client.js.map +1 -1
- package/dist/deere.d.ts +14 -0
- package/dist/deere.d.ts.map +1 -1
- package/dist/deere.js +20 -0
- package/dist/deere.js.map +1 -1
- package/dist/environment-resolver.d.ts +40 -0
- package/dist/environment-resolver.d.ts.map +1 -0
- package/dist/environment-resolver.js +79 -0
- package/dist/environment-resolver.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +54 -0
- package/dist/errors.js.map +1 -0
- package/dist/hateoas-map.d.ts +9 -0
- package/dist/hateoas-map.d.ts.map +1 -1
- package/dist/hateoas-map.js +84 -37
- package/dist/hateoas-map.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/safe/field-operations.d.ts +73 -0
- package/dist/safe/field-operations.d.ts.map +1 -0
- package/dist/safe/field-operations.js +74 -0
- package/dist/safe/field-operations.js.map +1 -0
- package/dist/safe/index.d.ts +41 -0
- package/dist/safe/index.d.ts.map +1 -0
- package/dist/safe/index.js +47 -0
- package/dist/safe/index.js.map +1 -0
- package/dist/types/generated/field-operations-api.d.ts +17 -0
- package/dist/types/generated/field-operations-api.d.ts.map +1 -1
- package/dist/types/generated/index.d.ts +1 -1
- package/dist/types/generated/index.js +1 -1
- package/package.json +3 -2
- package/dist/api/field-operations.d.ts +0 -83
- package/dist/api/field-operations.d.ts.map +0 -1
- package/dist/api/field-operations.js +0 -134
- package/dist/api/field-operations.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime URL resolver for spec-aware requests.
|
|
3
|
+
*
|
|
4
|
+
* Pure, deterministic, and side-effect-free. Every DeereClient request goes
|
|
5
|
+
* through `resolveRequestUrl` to turn a (spec, path, environment) tuple into
|
|
6
|
+
* a full URL — or throw a clear, actionable error before any HTTP call.
|
|
7
|
+
*
|
|
8
|
+
* Design note: no heuristics, no silent fallbacks. If the spec's static map
|
|
9
|
+
* doesn't cover the current environment, we throw. Sandbox vs prod is a
|
|
10
|
+
* trust boundary — falling back silently could delete customer data.
|
|
11
|
+
*/
|
|
12
|
+
import { type Environment, type SpecName } from './api-servers.generated.js';
|
|
13
|
+
import { DeereError } from './errors.js';
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when a spec has no server configuration (missing/malformed
|
|
16
|
+
* servers block, or generator classified it as 'unavailable').
|
|
17
|
+
*/
|
|
18
|
+
export declare class NoServerConfigError extends DeereError {
|
|
19
|
+
constructor(specName: string, reason?: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when a spec is available but does not support the requested
|
|
23
|
+
* environment. The error message lists supported envs + concrete alternatives.
|
|
24
|
+
*/
|
|
25
|
+
export declare class UnsupportedEnvironmentError extends DeereError {
|
|
26
|
+
constructor(specName: string, environment: string, supported: readonly string[]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a request URL for the given spec and environment.
|
|
30
|
+
*
|
|
31
|
+
* @param specName Name of the OpenAPI spec (e.g. 'equipment', 'organizations').
|
|
32
|
+
* @param path Relative path starting with '/' or '?' (generated code always emits this).
|
|
33
|
+
* @param environment Environment from the DeereClient config.
|
|
34
|
+
* @returns The full URL ready for `fetch`.
|
|
35
|
+
* @throws NoServerConfigError if the spec isn't in API_SERVERS or is unavailable.
|
|
36
|
+
* @throws UnsupportedEnvironmentError if the spec is static and the env isn't in its map.
|
|
37
|
+
* @throws Error if the path doesn't start with '/' or '?' (developer error guard).
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveRequestUrl(specName: SpecName | string, path: string, environment: Environment): string;
|
|
40
|
+
//# sourceMappingURL=environment-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-resolver.d.ts","sourceRoot":"","sources":["../src/environment-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAe,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAuB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAY9C;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,UAAU;gBAC7C,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE;CAchF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAC3B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,GACvB,MAAM,CAmCR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime URL resolver for spec-aware requests.
|
|
3
|
+
*
|
|
4
|
+
* Pure, deterministic, and side-effect-free. Every DeereClient request goes
|
|
5
|
+
* through `resolveRequestUrl` to turn a (spec, path, environment) tuple into
|
|
6
|
+
* a full URL — or throw a clear, actionable error before any HTTP call.
|
|
7
|
+
*
|
|
8
|
+
* Design note: no heuristics, no silent fallbacks. If the spec's static map
|
|
9
|
+
* doesn't cover the current environment, we throw. Sandbox vs prod is a
|
|
10
|
+
* trust boundary — falling back silently could delete customer data.
|
|
11
|
+
*/
|
|
12
|
+
import { API_SERVERS } from './api-servers.generated.js';
|
|
13
|
+
import { CLIENT_ERROR_STATUS, DeereError } from './errors.js';
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when a spec has no server configuration (missing/malformed
|
|
16
|
+
* servers block, or generator classified it as 'unavailable').
|
|
17
|
+
*/
|
|
18
|
+
export class NoServerConfigError extends DeereError {
|
|
19
|
+
constructor(specName, reason) {
|
|
20
|
+
super(`Spec '${specName}' has no server configuration.${reason
|
|
21
|
+
? ` ${reason}`
|
|
22
|
+
: " Its OpenAPI file is missing a 'servers' block or has a malformed URL."}`, CLIENT_ERROR_STATUS, 'NoServerConfig');
|
|
23
|
+
this.name = 'NoServerConfigError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when a spec is available but does not support the requested
|
|
28
|
+
* environment. The error message lists supported envs + concrete alternatives.
|
|
29
|
+
*/
|
|
30
|
+
export class UnsupportedEnvironmentError extends DeereError {
|
|
31
|
+
constructor(specName, environment, supported) {
|
|
32
|
+
const supportedList = supported.length > 0 ? supported.join(', ') : '(none)';
|
|
33
|
+
super(`The '${specName}' API does not support environment '${environment}'.\n\n` +
|
|
34
|
+
`Supported environments for this spec: ${supportedList}.\n\n` +
|
|
35
|
+
`This usually means the underlying JD backend has a different tier ` +
|
|
36
|
+
`structure than the platform APIs (the ISG proxy uses qual/cert/prod ` +
|
|
37
|
+
`tiers, with no sandbox or dev tier). For testing, try environment ` +
|
|
38
|
+
`'apiqa.tal' (qual tier). For production, use 'api' (prod tier).`, CLIENT_ERROR_STATUS, 'UnsupportedEnvironment');
|
|
39
|
+
this.name = 'UnsupportedEnvironmentError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolves a request URL for the given spec and environment.
|
|
44
|
+
*
|
|
45
|
+
* @param specName Name of the OpenAPI spec (e.g. 'equipment', 'organizations').
|
|
46
|
+
* @param path Relative path starting with '/' or '?' (generated code always emits this).
|
|
47
|
+
* @param environment Environment from the DeereClient config.
|
|
48
|
+
* @returns The full URL ready for `fetch`.
|
|
49
|
+
* @throws NoServerConfigError if the spec isn't in API_SERVERS or is unavailable.
|
|
50
|
+
* @throws UnsupportedEnvironmentError if the spec is static and the env isn't in its map.
|
|
51
|
+
* @throws Error if the path doesn't start with '/' or '?' (developer error guard).
|
|
52
|
+
*/
|
|
53
|
+
export function resolveRequestUrl(specName, path, environment) {
|
|
54
|
+
// Defensive invariant: generated code always emits paths with a leading '/'.
|
|
55
|
+
// This guard catches manual callers passing `client.get('spec', 'relative')`
|
|
56
|
+
// by mistake, turning a silent 404 on `host+relative` into a clear error.
|
|
57
|
+
if (path && !path.startsWith('/') && !path.startsWith('?')) {
|
|
58
|
+
throw new Error(`Invalid path '${path}': must start with '/' (e.g., '/organizations') ` +
|
|
59
|
+
`or '?' for query-only paths.`);
|
|
60
|
+
}
|
|
61
|
+
const config = API_SERVERS[specName];
|
|
62
|
+
if (!config) {
|
|
63
|
+
throw new NoServerConfigError(specName);
|
|
64
|
+
}
|
|
65
|
+
if (config.kind === 'unavailable') {
|
|
66
|
+
throw new NoServerConfigError(specName, config.reason);
|
|
67
|
+
}
|
|
68
|
+
if (config.kind === 'templated') {
|
|
69
|
+
const baseUrl = config.urlTemplate.replace('{environment}', environment);
|
|
70
|
+
return `${baseUrl}${path}`;
|
|
71
|
+
}
|
|
72
|
+
// kind === 'static' — partial map, throw on unsupported env
|
|
73
|
+
const baseUrl = config.urlByEnvironment[environment];
|
|
74
|
+
if (!baseUrl) {
|
|
75
|
+
throw new UnsupportedEnvironmentError(specName, environment, Object.keys(config.urlByEnvironment));
|
|
76
|
+
}
|
|
77
|
+
return `${baseUrl}${path}`;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=environment-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-resolver.js","sourceRoot":"","sources":["../src/environment-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAmC,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,YAAY,QAAgB,EAAE,MAAe;QAC3C,KAAK,CACH,SAAS,QAAQ,iCACf,MAAM;YACJ,CAAC,CAAC,IAAI,MAAM,EAAE;YACd,CAAC,CAAC,wEACN,EAAE,EACF,mBAAmB,EACnB,gBAAgB,CACjB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,UAAU;IACzD,YAAY,QAAgB,EAAE,WAAmB,EAAE,SAA4B;QAC7E,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC7E,K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ACnC,QAAQ,EACR,WAAW,EACX,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACrC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error hierarchy for deere-sdk.
|
|
3
|
+
*
|
|
4
|
+
* Lives in a separate file from client.ts to avoid a circular import with
|
|
5
|
+
* environment-resolver.ts (which needs DeereError to build its own
|
|
6
|
+
* NoServerConfigError and UnsupportedEnvironmentError).
|
|
7
|
+
*
|
|
8
|
+
* client.ts re-exports everything here for backward compatibility with any
|
|
9
|
+
* consumer that imports these classes from 'deere-sdk' main entry.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DeereError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly statusText: string;
|
|
14
|
+
readonly body?: unknown | undefined;
|
|
15
|
+
constructor(message: string, status: number, statusText: string, body?: unknown | undefined);
|
|
16
|
+
}
|
|
17
|
+
export declare class RateLimitError extends DeereError {
|
|
18
|
+
readonly retryAfter?: number | undefined;
|
|
19
|
+
constructor(message: string, status: number, statusText: string, retryAfter?: number | undefined, body?: unknown);
|
|
20
|
+
}
|
|
21
|
+
export declare class AuthError extends DeereError {
|
|
22
|
+
constructor(message: string, status: number, statusText: string, body?: unknown);
|
|
23
|
+
}
|
|
24
|
+
export declare class HateoasError extends Error {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly cause?: Error | undefined;
|
|
27
|
+
constructor(message: string, path: string, cause?: Error | undefined);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sentinel status for client-side errors that were never sent over HTTP.
|
|
31
|
+
* Distinct from HTTP 0 (which requestUrl uses for timeouts), so the retry
|
|
32
|
+
* logic in requestUrl that checks `error.status === 0 && error.statusText ===
|
|
33
|
+
* 'Timeout'` never fires for config/resolver errors.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CLIENT_ERROR_STATUS = -1;
|
|
36
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,qBAAa,UAAW,SAAQ,KAAK;aAGjB,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,IAAI,CAAC,EAAE,OAAO;gBAH9B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,OAAO,YAAA;CAKjC;AAED,qBAAa,cAAe,SAAQ,UAAU;aAK1B,UAAU,CAAC,EAAE,MAAM;gBAHnC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EACF,UAAU,CAAC,EAAE,MAAM,YAAA,EACnC,IAAI,CAAC,EAAE,OAAO;CAKjB;AAED,qBAAa,SAAU,SAAQ,UAAU;gBAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAIhF;AAED,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,MAAM;aACZ,KAAK,CAAC,EAAE,KAAK;gBAF7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,KAAK,YAAA;CAKhC;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error hierarchy for deere-sdk.
|
|
3
|
+
*
|
|
4
|
+
* Lives in a separate file from client.ts to avoid a circular import with
|
|
5
|
+
* environment-resolver.ts (which needs DeereError to build its own
|
|
6
|
+
* NoServerConfigError and UnsupportedEnvironmentError).
|
|
7
|
+
*
|
|
8
|
+
* client.ts re-exports everything here for backward compatibility with any
|
|
9
|
+
* consumer that imports these classes from 'deere-sdk' main entry.
|
|
10
|
+
*/
|
|
11
|
+
export class DeereError extends Error {
|
|
12
|
+
status;
|
|
13
|
+
statusText;
|
|
14
|
+
body;
|
|
15
|
+
constructor(message, status, statusText, body) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.statusText = statusText;
|
|
19
|
+
this.body = body;
|
|
20
|
+
this.name = 'DeereError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class RateLimitError extends DeereError {
|
|
24
|
+
retryAfter;
|
|
25
|
+
constructor(message, status, statusText, retryAfter, body) {
|
|
26
|
+
super(message, status, statusText, body);
|
|
27
|
+
this.retryAfter = retryAfter;
|
|
28
|
+
this.name = 'RateLimitError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class AuthError extends DeereError {
|
|
32
|
+
constructor(message, status, statusText, body) {
|
|
33
|
+
super(message, status, statusText, body);
|
|
34
|
+
this.name = 'AuthError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class HateoasError extends Error {
|
|
38
|
+
path;
|
|
39
|
+
cause;
|
|
40
|
+
constructor(message, path, cause) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.path = path;
|
|
43
|
+
this.cause = cause;
|
|
44
|
+
this.name = 'HateoasError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Sentinel status for client-side errors that were never sent over HTTP.
|
|
49
|
+
* Distinct from HTTP 0 (which requestUrl uses for timeouts), so the retry
|
|
50
|
+
* logic in requestUrl that checks `error.status === 0 && error.statusText ===
|
|
51
|
+
* 'Timeout'` never fires for config/resolver errors.
|
|
52
|
+
*/
|
|
53
|
+
export const CLIENT_ERROR_STATUS = -1;
|
|
54
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0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dist/hateoas-map.d.ts
CHANGED
|
@@ -6,11 +6,20 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @generated by generate-sdk.ts — do not edit manually
|
|
8
8
|
*/
|
|
9
|
+
import type { SpecName } from './api-servers.generated.js';
|
|
9
10
|
export interface HateoasRoute {
|
|
10
11
|
/** Path pattern of the parent resource (with parameter placeholders) */
|
|
11
12
|
parentPath: string;
|
|
12
13
|
/** HAL link relation name to follow from the parent response */
|
|
13
14
|
rel: string;
|
|
15
|
+
/**
|
|
16
|
+
* Which OpenAPI spec declares the parent resource. Required for cross-spec
|
|
17
|
+
* HATEOAS: if a child lives in equipment.yaml but its parent
|
|
18
|
+
* /organizations/{orgId} is declared in organizations.yaml, the client
|
|
19
|
+
* must fetch the parent via organizations.yaml's host (platform) not
|
|
20
|
+
* equipment.yaml's host (equipmentapi.deere.com/isg).
|
|
21
|
+
*/
|
|
22
|
+
parentSpec: SpecName;
|
|
14
23
|
}
|
|
15
24
|
export declare const HATEOAS_MAP: Record<string, HateoasRoute>;
|
|
16
25
|
//# sourceMappingURL=hateoas-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hateoas-map.d.ts","sourceRoot":"","sources":["../src/hateoas-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"hateoas-map.d.ts","sourceRoot":"","sources":["../src/hateoas-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,UAAU,EAAE,QAAQ,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsKpD,CAAC"}
|
package/dist/hateoas-map.js
CHANGED
|
@@ -7,123 +7,170 @@
|
|
|
7
7
|
* @generated by generate-sdk.ts — do not edit manually
|
|
8
8
|
*/
|
|
9
9
|
export const HATEOAS_MAP = {
|
|
10
|
-
'/assets/{assetId}/locations': {
|
|
10
|
+
'/assets/{assetId}/locations': {
|
|
11
|
+
parentPath: '/assets/{assetId}',
|
|
12
|
+
rel: 'locations',
|
|
13
|
+
parentSpec: 'assets',
|
|
14
|
+
},
|
|
11
15
|
'/equipmentMakes/{equipmentMakeId}/equipmentISGTypes': {
|
|
12
16
|
parentPath: '/equipmentMakes/{equipmentMakeId}',
|
|
13
17
|
rel: 'equipmentISGTypes',
|
|
18
|
+
parentSpec: 'equipment',
|
|
14
19
|
},
|
|
15
20
|
'/equipmentMakes/{equipmentMakeId}/equipmentISGTypes/{equipmentISGTypeId}/equipmentModels': {
|
|
16
21
|
parentPath: '/equipmentMakes/{equipmentMakeId}/equipmentISGTypes/{equipmentISGTypeId}',
|
|
17
22
|
rel: 'equipmentModels',
|
|
23
|
+
parentSpec: 'equipment',
|
|
18
24
|
},
|
|
19
25
|
'/equipmentMakes/{equipmentMakeId}/equipmentTypes': {
|
|
20
26
|
parentPath: '/equipmentMakes/{equipmentMakeId}',
|
|
21
27
|
rel: 'equipmentTypes',
|
|
28
|
+
parentSpec: 'equipment',
|
|
22
29
|
},
|
|
23
30
|
'/fieldOperations/{operationId}/boundary': {
|
|
24
31
|
parentPath: '/fieldOperations/{operationId}',
|
|
25
32
|
rel: 'boundary',
|
|
26
|
-
|
|
27
|
-
'/machines/{principalId}/alerts': { parentPath: '/machines/{principalId}', rel: 'alerts' },
|
|
28
|
-
'/machines/{principalId}/deviceStateReports': {
|
|
29
|
-
parentPath: '/machines/{principalId}',
|
|
30
|
-
rel: 'deviceStateReports',
|
|
31
|
-
},
|
|
32
|
-
'/machines/{principalId}/engineHours': {
|
|
33
|
-
parentPath: '/machines/{principalId}',
|
|
34
|
-
rel: 'engineHours',
|
|
35
|
-
},
|
|
36
|
-
'/machines/{principalId}/hoursOfOperation': {
|
|
37
|
-
parentPath: '/machines/{principalId}',
|
|
38
|
-
rel: 'hoursOfOperation',
|
|
39
|
-
},
|
|
40
|
-
'/machines/{principalId}/locationHistory': {
|
|
41
|
-
parentPath: '/machines/{principalId}',
|
|
42
|
-
rel: 'locationHistory',
|
|
33
|
+
parentSpec: 'field-operations-api',
|
|
43
34
|
},
|
|
44
35
|
'/organizations/{organizationId}/cropTypes': {
|
|
45
36
|
parentPath: '/organizations/{organizationId}',
|
|
46
37
|
rel: 'cropTypes',
|
|
38
|
+
parentSpec: 'organizations',
|
|
47
39
|
},
|
|
48
40
|
'/organizations/{organizationId}/equipment': {
|
|
49
41
|
parentPath: '/organizations/{organizationId}',
|
|
50
42
|
rel: 'equipment',
|
|
51
|
-
|
|
52
|
-
'/organizations/{organizationId}/equipment/{principalId}/measurements': {
|
|
53
|
-
parentPath: '/organizations/{organizationId}/equipment/{principalId}',
|
|
54
|
-
rel: 'measurements',
|
|
43
|
+
parentSpec: 'organizations',
|
|
55
44
|
},
|
|
56
45
|
'/organizations/{organizationId}/varieties': {
|
|
57
46
|
parentPath: '/organizations/{organizationId}',
|
|
58
47
|
rel: 'varieties',
|
|
48
|
+
parentSpec: 'organizations',
|
|
49
|
+
},
|
|
50
|
+
'/organizations/{orgId}/assets': {
|
|
51
|
+
parentPath: '/organizations/{orgId}',
|
|
52
|
+
rel: 'assets',
|
|
53
|
+
parentSpec: 'organizations',
|
|
54
|
+
},
|
|
55
|
+
'/organizations/{orgId}/boundaries': {
|
|
56
|
+
parentPath: '/organizations/{orgId}',
|
|
57
|
+
rel: 'boundaries',
|
|
58
|
+
parentSpec: 'organizations',
|
|
59
|
+
},
|
|
60
|
+
'/organizations/{orgId}/clients': {
|
|
61
|
+
parentPath: '/organizations/{orgId}',
|
|
62
|
+
rel: 'clients',
|
|
63
|
+
parentSpec: 'organizations',
|
|
59
64
|
},
|
|
60
|
-
'/organizations/{orgId}/assets': { parentPath: '/organizations/{orgId}', rel: 'assets' },
|
|
61
|
-
'/organizations/{orgId}/boundaries': { parentPath: '/organizations/{orgId}', rel: 'boundaries' },
|
|
62
|
-
'/organizations/{orgId}/clients': { parentPath: '/organizations/{orgId}', rel: 'clients' },
|
|
63
65
|
'/organizations/{orgId}/clients/{id}/farms': {
|
|
64
66
|
parentPath: '/organizations/{orgId}/clients/{id}',
|
|
65
67
|
rel: 'farms',
|
|
68
|
+
parentSpec: 'clients',
|
|
66
69
|
},
|
|
67
70
|
'/organizations/{orgID}/clients/{id}/fields': {
|
|
68
71
|
parentPath: '/organizations/{orgID}/clients/{id}',
|
|
69
72
|
rel: 'fields',
|
|
73
|
+
parentSpec: 'clients',
|
|
70
74
|
},
|
|
71
75
|
'/organizations/{orgId}/connections': {
|
|
72
76
|
parentPath: '/organizations/{orgId}',
|
|
73
77
|
rel: 'connections',
|
|
78
|
+
parentSpec: 'organizations',
|
|
79
|
+
},
|
|
80
|
+
'/organizations/{orgId}/farms': {
|
|
81
|
+
parentPath: '/organizations/{orgId}',
|
|
82
|
+
rel: 'farms',
|
|
83
|
+
parentSpec: 'organizations',
|
|
74
84
|
},
|
|
75
|
-
'/organizations/{orgId}/farms': { parentPath: '/organizations/{orgId}', rel: 'farms' },
|
|
76
85
|
'/organizations/{orgId}/farms/{farmId}/clients': {
|
|
77
86
|
parentPath: '/organizations/{orgId}/farms/{farmId}',
|
|
78
87
|
rel: 'clients',
|
|
88
|
+
parentSpec: 'farms',
|
|
79
89
|
},
|
|
80
90
|
'/organizations/{orgID}/farms/{id}/fields': {
|
|
81
91
|
parentPath: '/organizations/{orgID}/farms/{id}',
|
|
82
92
|
rel: 'fields',
|
|
93
|
+
parentSpec: 'farms',
|
|
94
|
+
},
|
|
95
|
+
'/organizations/{orgId}/fields': {
|
|
96
|
+
parentPath: '/organizations/{orgId}',
|
|
97
|
+
rel: 'fields',
|
|
98
|
+
parentSpec: 'organizations',
|
|
83
99
|
},
|
|
84
|
-
'/organizations/{orgId}/fields': { parentPath: '/organizations/{orgId}', rel: 'fields' },
|
|
85
100
|
'/organizations/{orgId}/fields/{fieldId}/boundaries': {
|
|
86
101
|
parentPath: '/organizations/{orgId}/fields/{fieldId}',
|
|
87
102
|
rel: 'boundaries',
|
|
103
|
+
parentSpec: 'fields',
|
|
88
104
|
},
|
|
89
105
|
'/organizations/{orgId}/fields/{fieldId}/farms': {
|
|
90
106
|
parentPath: '/organizations/{orgId}/fields/{fieldId}',
|
|
91
107
|
rel: 'farms',
|
|
108
|
+
parentSpec: 'fields',
|
|
92
109
|
},
|
|
93
110
|
'/organizations/{orgId}/fields/{fieldId}/fieldOperations': {
|
|
94
111
|
parentPath: '/organizations/{orgId}/fields/{fieldId}',
|
|
95
112
|
rel: 'fieldOperations',
|
|
113
|
+
parentSpec: 'fields',
|
|
96
114
|
},
|
|
97
115
|
'/organizations/{orgId}/fields/{fieldId}/flags': {
|
|
98
116
|
parentPath: '/organizations/{orgId}/fields/{fieldId}',
|
|
99
117
|
rel: 'flags',
|
|
118
|
+
parentSpec: 'fields',
|
|
100
119
|
},
|
|
101
120
|
'/organizations/{orgId}/fields/{fieldId}/guidanceLines': {
|
|
102
121
|
parentPath: '/organizations/{orgId}/fields/{fieldId}',
|
|
103
122
|
rel: 'guidanceLines',
|
|
123
|
+
parentSpec: 'fields',
|
|
104
124
|
},
|
|
105
125
|
'/organizations/{orgID}/fields/{id}/clients': {
|
|
106
126
|
parentPath: '/organizations/{orgID}/fields/{id}',
|
|
107
127
|
rel: 'clients',
|
|
128
|
+
parentSpec: 'fields',
|
|
108
129
|
},
|
|
109
130
|
'/organizations/{orgId}/fields/{id}/mapLayerSummaries': {
|
|
110
131
|
parentPath: '/organizations/{orgId}/fields/{id}',
|
|
111
132
|
rel: 'mapLayerSummaries',
|
|
133
|
+
parentSpec: 'fields',
|
|
134
|
+
},
|
|
135
|
+
'/organizations/{orgId}/files': {
|
|
136
|
+
parentPath: '/organizations/{orgId}',
|
|
137
|
+
rel: 'files',
|
|
138
|
+
parentSpec: 'organizations',
|
|
139
|
+
},
|
|
140
|
+
'/organizations/{orgId}/flags': {
|
|
141
|
+
parentPath: '/organizations/{orgId}',
|
|
142
|
+
rel: 'flags',
|
|
143
|
+
parentSpec: 'organizations',
|
|
112
144
|
},
|
|
113
|
-
'/organizations/{orgId}/files': { parentPath: '/organizations/{orgId}', rel: 'files' },
|
|
114
|
-
'/organizations/{orgId}/flags': { parentPath: '/organizations/{orgId}', rel: 'flags' },
|
|
115
145
|
'/organizations/{orgId}/harvestIdentificationModules': {
|
|
116
146
|
parentPath: '/organizations/{orgId}',
|
|
117
147
|
rel: 'harvestIdentificationModules',
|
|
148
|
+
parentSpec: 'organizations',
|
|
149
|
+
},
|
|
150
|
+
'/organizations/{orgId}/operators': {
|
|
151
|
+
parentPath: '/organizations/{orgId}',
|
|
152
|
+
rel: 'operators',
|
|
153
|
+
parentSpec: 'organizations',
|
|
154
|
+
},
|
|
155
|
+
'/organizations/{orgId}/users': {
|
|
156
|
+
parentPath: '/organizations/{orgId}',
|
|
157
|
+
rel: 'users',
|
|
158
|
+
parentSpec: 'organizations',
|
|
159
|
+
},
|
|
160
|
+
'/partnerships/{token}/permissions': {
|
|
161
|
+
parentPath: '/partnerships/{token}',
|
|
162
|
+
rel: 'permissions',
|
|
163
|
+
parentSpec: 'partnerships',
|
|
164
|
+
},
|
|
165
|
+
'/users/{userName}/organizations': {
|
|
166
|
+
parentPath: '/users/{userName}',
|
|
167
|
+
rel: 'organizations',
|
|
168
|
+
parentSpec: 'users',
|
|
118
169
|
},
|
|
119
|
-
'/
|
|
120
|
-
parentPath: '/
|
|
121
|
-
rel: '
|
|
170
|
+
'/varieties/{erid}/documents': {
|
|
171
|
+
parentPath: '/varieties/{erid}',
|
|
172
|
+
rel: 'documents',
|
|
173
|
+
parentSpec: 'products',
|
|
122
174
|
},
|
|
123
|
-
'/organizations/{orgId}/operators': { parentPath: '/organizations/{orgId}', rel: 'operators' },
|
|
124
|
-
'/organizations/{orgId}/users': { parentPath: '/organizations/{orgId}', rel: 'users' },
|
|
125
|
-
'/partnerships/{token}/permissions': { parentPath: '/partnerships/{token}', rel: 'permissions' },
|
|
126
|
-
'/users/{userName}/organizations': { parentPath: '/users/{userName}', rel: 'organizations' },
|
|
127
|
-
'/varieties/{erid}/documents': { parentPath: '/varieties/{erid}', rel: 'documents' },
|
|
128
175
|
};
|
|
129
176
|
//# sourceMappingURL=hateoas-map.js.map
|
package/dist/hateoas-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hateoas-map.js","sourceRoot":"","sources":["../src/hateoas-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"hateoas-map.js","sourceRoot":"","sources":["../src/hateoas-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,MAAM,CAAC,MAAM,WAAW,GAAiC;IACvD,6BAA6B,EAAE;QAC7B,UAAU,EAAE,mBAAmB;QAC/B,GAAG,EAAE,WAAW;QAChB,UAAU,EAAE,QAAQ;KACrB;IACD,qDAAqD,EAAE;QACrD,UAAU,EAAE,mCAAmC;QAC/C,GAAG,EAAE,mBAAmB;QACxB,UAAU,EAAE,WAAW;KACxB;IACD,0FAA0F,EAAE;QAC1F,UAAU,EAAE,0EAA0E;QACtF,GAAG,EAAE,iBAAiB;QACtB,UAAU,EAAE,WAAW;KACxB;IACD,kDAAkD,EAAE;QAClD,UAAU,EAAE,mCAAmC;QAC/C,GAAG,EAAE,gBAAgB;QACrB,UAAU,EAAE,WAAW;KACxB;IACD,yCAAyC,EAAE;QACzC,UAAU,EAAE,gCAAgC;QAC5C,GAAG,EAAE,UAAU;QACf,UAAU,EAAE,sBAAsB;KACnC;IACD,2CAA2C,EAAE;QAC3C,UAAU,EAAE,iCAAiC;Q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OAAO;QACZ,UAAU,EAAE,eAAe;KAC5B;IACD,mCAAmC,EAAE;QACnC,UAAU,EAAE,uBAAuB;QACnC,GAAG,EAAE,aAAa;QAClB,UAAU,EAAE,cAAc;KAC3B;IACD,iCAAiC,EAAE;QACjC,UAAU,EAAE,mBAAmB;QAC/B,GAAG,EAAE,eAAe;QACpB,UAAU,EAAE,OAAO;KACpB;IACD,6BAA6B,EAAE;QAC7B,UAAU,EAAE,mBAAmB;QAC/B,GAAG,EAAE,WAAW;QAChB,UAAU,EAAE,UAAU;KACvB;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -32,5 +32,6 @@ export * from './api/index.js';
|
|
|
32
32
|
export type { DeereClientConfig, Environment, Link, PaginatedResponse, RequestOptions, } from './client.js';
|
|
33
33
|
export { AuthError, createClient, DeereClient, DeereError, HateoasError, RateLimitError, } from './client.js';
|
|
34
34
|
export { createDeere, Deere } from './deere.js';
|
|
35
|
+
export { type FieldOperationWithMeasurements, SafeFacades, SafeFieldOperationsApi, } from './safe/index.js';
|
|
35
36
|
export * as Types from './types/index.js';
|
|
36
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIhD,OAAO,EACL,KAAK,8BAA8B,EACnC,WAAW,EACX,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ export * from './api/index.js';
|
|
|
34
34
|
export { AuthError, createClient, DeereClient, DeereError, HateoasError, RateLimitError, } from './client.js';
|
|
35
35
|
// Main SDK class
|
|
36
36
|
export { createDeere, Deere } from './deere.js';
|
|
37
|
+
// Safe facades that force query params the raw API leaves optional.
|
|
38
|
+
// See scripts/embed-contracts.yaml and src/safe/ for context.
|
|
39
|
+
export { SafeFacades, SafeFieldOperationsApi, } from './safe/index.js';
|
|
37
40
|
// OpenAPI Types (for advanced usage)
|
|
38
41
|
export * as Types from './types/index.js';
|
|
39
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,cAAc;AACd,cAAc,gBAAgB,CAAC;AAQ/B,mBAAmB;AACnB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhD,qCAAqC;AACrC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,cAAc;AACd,cAAc,gBAAgB,CAAC;AAQ/B,mBAAmB;AACnB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhD,oEAAoE;AACpE,8DAA8D;AAC9D,OAAO,EAEL,WAAW,EACX,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,qCAAqC;AACrC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SafeFieldOperationsApi — hand-written facade over the generated
|
|
3
|
+
* FieldOperationsApi.
|
|
4
|
+
*
|
|
5
|
+
* The raw FieldOperationsApi.listAll() takes an optional embed param. John
|
|
6
|
+
* Deere's API silently omits the measurementTypes array on returned
|
|
7
|
+
* FieldOperation objects unless the request passes ?embed=measurementTypes,
|
|
8
|
+
* and JD's OpenAPI spec never encodes that invariant. Three separate times in
|
|
9
|
+
* FieldMCP, developers called listAll without the embed param and shipped
|
|
10
|
+
* placeholder zeros to production because the downstream normalizer couldn't
|
|
11
|
+
* distinguish "missing data" from "real zero." The safe wrapper makes the
|
|
12
|
+
* forcing function syntactic: you can't call listAllWithMeasurements without
|
|
13
|
+
* the embed param, because the wrapper adds it for you.
|
|
14
|
+
*
|
|
15
|
+
* See scripts/embed-contracts.yaml for the contract registry that makes the
|
|
16
|
+
* narrowed type (measurementTypes non-optional) honest at the type level.
|
|
17
|
+
*/
|
|
18
|
+
import type { FieldOperationsApi } from '../api/field-operations-api.js';
|
|
19
|
+
import type { components } from '../types/generated/field-operations-api.js';
|
|
20
|
+
type RawFieldOperation = components['schemas']['FieldOperation'];
|
|
21
|
+
type FieldOperationMeasurement = components['schemas']['FieldOperationMeasurement'];
|
|
22
|
+
/**
|
|
23
|
+
* A FieldOperation guaranteed to carry its measurementTypes array.
|
|
24
|
+
*
|
|
25
|
+
* The raw `FieldOperation` type marks `measurementTypes` as optional because
|
|
26
|
+
* JD's API populates it only when `?embed=measurementTypes` is passed.
|
|
27
|
+
* `SafeFieldOperationsApi.listAllWithMeasurements()` forces the embed param
|
|
28
|
+
* AND verifies every returned operation actually carries the array (throwing
|
|
29
|
+
* `DeereError` on contract violation), so the narrowed type is honest, not
|
|
30
|
+
* a cast over a possible `undefined`.
|
|
31
|
+
*
|
|
32
|
+
* An empty `measurementTypes: []` is valid (operation exists but has no
|
|
33
|
+
* recorded measurements yet). `undefined` is a contract violation and throws.
|
|
34
|
+
*/
|
|
35
|
+
export type FieldOperationWithMeasurements = RawFieldOperation & {
|
|
36
|
+
measurementTypes: FieldOperationMeasurement[];
|
|
37
|
+
};
|
|
38
|
+
type RawListAllParams = NonNullable<Parameters<FieldOperationsApi['listAll']>[2]>;
|
|
39
|
+
type SafeListAllParams = Omit<RawListAllParams, 'embed'>;
|
|
40
|
+
export declare class SafeFieldOperationsApi {
|
|
41
|
+
private readonly raw;
|
|
42
|
+
constructor(raw: FieldOperationsApi);
|
|
43
|
+
/**
|
|
44
|
+
* List all field operations on a field with measurement data embedded.
|
|
45
|
+
*
|
|
46
|
+
* Forces `embed=measurementTypes` on the outgoing request, so yield, area,
|
|
47
|
+
* moisture, application rate, and seeding population are guaranteed present
|
|
48
|
+
* where JD has recorded them. Empty `measurementTypes: []` is a valid
|
|
49
|
+
* response (JD has no measurements for that operation yet). `undefined`
|
|
50
|
+
* `measurementTypes` on any returned operation is treated as a contract
|
|
51
|
+
* violation and throws `DeereError` naming the offending operation id.
|
|
52
|
+
*
|
|
53
|
+
* Prefer this over `deere.fieldOperations.listAll` when your code reads
|
|
54
|
+
* yield, rate, or any other field under `measurementTypes`. The raw method
|
|
55
|
+
* silently returns FieldOperation objects with `measurementTypes` omitted
|
|
56
|
+
* unless the caller remembers to pass the embed param, and has caused
|
|
57
|
+
* production bugs in FieldMCP three separate times.
|
|
58
|
+
*
|
|
59
|
+
* @param orgId The John Deere organization id.
|
|
60
|
+
* @param fieldId The field id within that organization.
|
|
61
|
+
* @param params Optional filter params (cropSeason, fieldOperationType,
|
|
62
|
+
* date range, workPlanIds). Any `embed` value in params is
|
|
63
|
+
* ignored — the wrapper always overrides with
|
|
64
|
+
* `embed: 'measurementTypes'`.
|
|
65
|
+
* @throws {DeereError} If JD returns any operation without a
|
|
66
|
+
* `measurementTypes` array despite the embed param
|
|
67
|
+
* being passed. This indicates JD's wire format has
|
|
68
|
+
* drifted from the documented contract.
|
|
69
|
+
*/
|
|
70
|
+
listAllWithMeasurements(orgId: string, fieldId: string, params?: SafeListAllParams): Promise<FieldOperationWithMeasurements[]>;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=field-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-operations.d.ts","sourceRoot":"","sources":["../../src/safe/field-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAE7E,KAAK,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC;AACjE,KAAK,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAAC,CAAC;AAEpF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,GAAG;IAC/D,gBAAgB,EAAE,yBAAyB,EAAE,CAAC;CAC/C,CAAC;AAEF,KAAK,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEzD,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,kBAAkB;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,uBAAuB,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,8BAA8B,EAAE,CAAC;CA4B7C"}
|