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.
Files changed (159) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/README.md +130 -20
  3. package/dist/api/aemp.d.ts +4 -0
  4. package/dist/api/aemp.d.ts.map +1 -1
  5. package/dist/api/aemp.js +5 -1
  6. package/dist/api/aemp.js.map +1 -1
  7. package/dist/api/assets.d.ts +4 -0
  8. package/dist/api/assets.d.ts.map +1 -1
  9. package/dist/api/assets.js +13 -9
  10. package/dist/api/assets.js.map +1 -1
  11. package/dist/api/boundaries.d.ts +4 -0
  12. package/dist/api/boundaries.d.ts.map +1 -1
  13. package/dist/api/boundaries.js +12 -8
  14. package/dist/api/boundaries.js.map +1 -1
  15. package/dist/api/clients.d.ts +4 -0
  16. package/dist/api/clients.d.ts.map +1 -1
  17. package/dist/api/clients.js +12 -8
  18. package/dist/api/clients.js.map +1 -1
  19. package/dist/api/connection-management.d.ts +4 -0
  20. package/dist/api/connection-management.d.ts.map +1 -1
  21. package/dist/api/connection-management.js +8 -4
  22. package/dist/api/connection-management.js.map +1 -1
  23. package/dist/api/crop-types.d.ts +4 -0
  24. package/dist/api/crop-types.d.ts.map +1 -1
  25. package/dist/api/crop-types.js +9 -5
  26. package/dist/api/crop-types.js.map +1 -1
  27. package/dist/api/equipment-measurement.d.ts +4 -0
  28. package/dist/api/equipment-measurement.d.ts.map +1 -1
  29. package/dist/api/equipment-measurement.js +5 -1
  30. package/dist/api/equipment-measurement.js.map +1 -1
  31. package/dist/api/equipment.d.ts +4 -0
  32. package/dist/api/equipment.d.ts.map +1 -1
  33. package/dist/api/equipment.js +20 -16
  34. package/dist/api/equipment.js.map +1 -1
  35. package/dist/api/farms.d.ts +4 -0
  36. package/dist/api/farms.d.ts.map +1 -1
  37. package/dist/api/farms.js +12 -8
  38. package/dist/api/farms.js.map +1 -1
  39. package/dist/api/field-operations-api.d.ts +4 -0
  40. package/dist/api/field-operations-api.d.ts.map +1 -1
  41. package/dist/api/field-operations-api.js +8 -4
  42. package/dist/api/field-operations-api.js.map +1 -1
  43. package/dist/api/fields.d.ts +4 -0
  44. package/dist/api/fields.d.ts.map +1 -1
  45. package/dist/api/fields.js +12 -8
  46. package/dist/api/fields.js.map +1 -1
  47. package/dist/api/files.d.ts +4 -0
  48. package/dist/api/files.d.ts.map +1 -1
  49. package/dist/api/files.js +10 -6
  50. package/dist/api/files.js.map +1 -1
  51. package/dist/api/flags.d.ts +4 -0
  52. package/dist/api/flags.d.ts.map +1 -1
  53. package/dist/api/flags.js +11 -7
  54. package/dist/api/flags.js.map +1 -1
  55. package/dist/api/guidance-lines.d.ts +4 -0
  56. package/dist/api/guidance-lines.d.ts.map +1 -1
  57. package/dist/api/guidance-lines.js +9 -5
  58. package/dist/api/guidance-lines.js.map +1 -1
  59. package/dist/api/harvest-id.d.ts +4 -0
  60. package/dist/api/harvest-id.d.ts.map +1 -1
  61. package/dist/api/harvest-id.js +7 -3
  62. package/dist/api/harvest-id.js.map +1 -1
  63. package/dist/api/machine-alerts.d.ts +4 -0
  64. package/dist/api/machine-alerts.d.ts.map +1 -1
  65. package/dist/api/machine-alerts.js +6 -2
  66. package/dist/api/machine-alerts.js.map +1 -1
  67. package/dist/api/machine-device-state-reports.d.ts +4 -0
  68. package/dist/api/machine-device-state-reports.d.ts.map +1 -1
  69. package/dist/api/machine-device-state-reports.js +5 -1
  70. package/dist/api/machine-device-state-reports.js.map +1 -1
  71. package/dist/api/machine-engine-hours.d.ts +4 -0
  72. package/dist/api/machine-engine-hours.d.ts.map +1 -1
  73. package/dist/api/machine-engine-hours.js +6 -2
  74. package/dist/api/machine-engine-hours.js.map +1 -1
  75. package/dist/api/machine-hours-of-operation.d.ts +4 -0
  76. package/dist/api/machine-hours-of-operation.d.ts.map +1 -1
  77. package/dist/api/machine-hours-of-operation.js +6 -2
  78. package/dist/api/machine-hours-of-operation.js.map +1 -1
  79. package/dist/api/machine-locations.d.ts +4 -0
  80. package/dist/api/machine-locations.d.ts.map +1 -1
  81. package/dist/api/machine-locations.js +5 -1
  82. package/dist/api/machine-locations.js.map +1 -1
  83. package/dist/api/map-layers.d.ts +4 -0
  84. package/dist/api/map-layers.d.ts.map +1 -1
  85. package/dist/api/map-layers.js +9 -5
  86. package/dist/api/map-layers.js.map +1 -1
  87. package/dist/api/notifications.d.ts +4 -0
  88. package/dist/api/notifications.d.ts.map +1 -1
  89. package/dist/api/notifications.js +9 -5
  90. package/dist/api/notifications.js.map +1 -1
  91. package/dist/api/operators.d.ts +4 -0
  92. package/dist/api/operators.d.ts.map +1 -1
  93. package/dist/api/operators.js +11 -7
  94. package/dist/api/operators.js.map +1 -1
  95. package/dist/api/organizations.d.ts +4 -0
  96. package/dist/api/organizations.d.ts.map +1 -1
  97. package/dist/api/organizations.js +9 -5
  98. package/dist/api/organizations.js.map +1 -1
  99. package/dist/api/partnerships.d.ts +4 -0
  100. package/dist/api/partnerships.d.ts.map +1 -1
  101. package/dist/api/partnerships.js +11 -7
  102. package/dist/api/partnerships.js.map +1 -1
  103. package/dist/api/products.d.ts +4 -0
  104. package/dist/api/products.d.ts.map +1 -1
  105. package/dist/api/products.js +14 -10
  106. package/dist/api/products.js.map +1 -1
  107. package/dist/api/users.d.ts +4 -0
  108. package/dist/api/users.d.ts.map +1 -1
  109. package/dist/api/users.js +5 -1
  110. package/dist/api/users.js.map +1 -1
  111. package/dist/api/webhook.d.ts +4 -0
  112. package/dist/api/webhook.d.ts.map +1 -1
  113. package/dist/api/webhook.js +9 -5
  114. package/dist/api/webhook.js.map +1 -1
  115. package/dist/api-servers.generated.d.ts +72 -0
  116. package/dist/api-servers.generated.d.ts.map +1 -0
  117. package/dist/api-servers.generated.js +344 -0
  118. package/dist/api-servers.generated.js.map +1 -0
  119. package/dist/client.d.ts +95 -47
  120. package/dist/client.d.ts.map +1 -1
  121. package/dist/client.js +196 -105
  122. package/dist/client.js.map +1 -1
  123. package/dist/deere.d.ts +14 -0
  124. package/dist/deere.d.ts.map +1 -1
  125. package/dist/deere.js +20 -0
  126. package/dist/deere.js.map +1 -1
  127. package/dist/environment-resolver.d.ts +40 -0
  128. package/dist/environment-resolver.d.ts.map +1 -0
  129. package/dist/environment-resolver.js +79 -0
  130. package/dist/environment-resolver.js.map +1 -0
  131. package/dist/errors.d.ts +36 -0
  132. package/dist/errors.d.ts.map +1 -0
  133. package/dist/errors.js +54 -0
  134. package/dist/errors.js.map +1 -0
  135. package/dist/hateoas-map.d.ts +9 -0
  136. package/dist/hateoas-map.d.ts.map +1 -1
  137. package/dist/hateoas-map.js +84 -37
  138. package/dist/hateoas-map.js.map +1 -1
  139. package/dist/index.d.ts +1 -0
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +3 -0
  142. package/dist/index.js.map +1 -1
  143. package/dist/safe/field-operations.d.ts +73 -0
  144. package/dist/safe/field-operations.d.ts.map +1 -0
  145. package/dist/safe/field-operations.js +74 -0
  146. package/dist/safe/field-operations.js.map +1 -0
  147. package/dist/safe/index.d.ts +41 -0
  148. package/dist/safe/index.d.ts.map +1 -0
  149. package/dist/safe/index.js +47 -0
  150. package/dist/safe/index.js.map +1 -0
  151. package/dist/types/generated/field-operations-api.d.ts +17 -0
  152. package/dist/types/generated/field-operations-api.d.ts.map +1 -1
  153. package/dist/types/generated/index.d.ts +1 -1
  154. package/dist/types/generated/index.js +1 -1
  155. package/package.json +3 -2
  156. package/dist/api/field-operations.d.ts +0 -83
  157. package/dist/api/field-operations.d.ts.map +0 -1
  158. package/dist/api/field-operations.js +0 -134
  159. 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","sourceR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,KAAK,CACb,iBAAiB,IAAI,kDAAkD;YACrE,8BAA8B,CACjC,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,QAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QACzE,OAAO,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,4DAA4D;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,2BAA2B,CACnC,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"}
@@ -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.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,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;CACb;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuHpD,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"}
@@ -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': { parentPath: '/assets/{assetId}', rel: '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
- '/organizations/{orgId}/notifications/events': {
120
- parentPath: '/organizations/{orgId}/notifications',
121
- rel: 'events',
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
@@ -1 +1 @@
1
- {"version":3,"file":"hateoas-map.js","sourceRoot":"","sources":["../src/hateoas-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,MAAM,CAAC,MAAM,WAAW,GAAiC;IACvD,6BAA6B,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,EAAE,WAAW,EAAE;IACpF,qDAAqD,EAAE;QACrD,UAAU,EAAE,mCAAmC;QAC/C,GAAG,EAAE,mBAAmB;KACzB;IACD,0FAA0F,EAAE;QAC1F,UAAU,EAAE,0EAA0E;QACtF,GAAG,EAAE,iBAAiB;KACvB;IACD,kDAAkD,EAAE;QAClD,UAAU,EAAE,mCAAmC;QAC/C,GAAG,EAAE,gBAAgB;KACtB;IACD,yCAAyC,EAAE;QACzC,UAAU,EAAE,gCAAgC;QAC5C,GAAG,EAAE,UAAU;KAChB;IACD,gCAAgC,EAAE,EAAE,UAAU,EAAE,yBAAyB,EAAE,GAAG,EAAE,QAAQ,EAAE;IAC1F,4CAA4C,EAAE;QAC5C,UAAU,EAAE,yBAAyB;QACrC,GAAG,EAAE,oBAAoB;KAC1B;IACD,qCAAqC,EAAE;QACrC,UAAU,EAAE,yBAAyB;QACrC,GAAG,EAAE,aAAa;KACnB;IACD,0CAA0C,EAAE;QAC1C,UAAU,EAAE,yBAAyB;QACrC,GAAG,EAAE,kBAAkB;KACxB;IACD,yCAAyC,EAAE;QACzC,UAAU,EAAE,yBAAyB;QACrC,GAAG,EAAE,iBAAiB;KACvB;IACD,2CAA2C,EAAE;QAC3C,UAAU,EAAE,iCAAiC;QAC7C,GAAG,EAAE,WAAW;KACjB;IACD,2CAA2C,EAAE;QAC3C,UAAU,EAAE,iCAAiC;QAC7C,GAAG,EAAE,WAAW;KACjB;IACD,sEAAsE,EAAE;QACtE,UAAU,EAAE,yDA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8B,EAAE;QAC9B,UAAU,EAAE,wBAAwB;QACpC,GAAG,EAAE,OAAO;QACZ,UAAU,EAAE,eAAe;KAC5B;IACD,qDAAqD,EAAE;QACrD,UAAU,EAAE,wBAAwB;QACpC,GAAG,EAAE,8BAA8B;QACnC,UAAU,EAAE,eAAe;KAC5B;IACD,kCAAkC,EAAE;QAClC,UAAU,EAAE,wBAAwB;QACpC,GAAG,EAAE,WAAW;QAChB,UAAU,EAAE,eAAe;KAC5B;IACD,8BAA8B,EAAE;QAC9B,UAAU,EAAE,wBAAwB;QACpC,GAAG,EAAE,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
@@ -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;AAGhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,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"}