@leaflow/sdk 0.5.0 → 0.5.1
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/dist/http.d.ts +26 -0
- package/dist/http.js +49 -16
- package/dist/index.js +1 -1
- package/openapi/compute.version +1 -1
- package/package.json +1 -1
package/dist/http.d.ts
CHANGED
|
@@ -96,5 +96,31 @@ export type Bound<T> = {
|
|
|
96
96
|
* `scripts/check-generated-arity.mjs` fails the build if that changes: a slot
|
|
97
97
|
* that silently shifts by one would pass the client as somebody's request body,
|
|
98
98
|
* and no amount of type checking on generated code would catch it.
|
|
99
|
+
*
|
|
100
|
+
* # Why this builds an object instead of returning a Proxy
|
|
101
|
+
*
|
|
102
|
+
* It used to be a `Proxy` over the namespace, which is smaller and binds lazily.
|
|
103
|
+
* It also threw, in production only:
|
|
104
|
+
*
|
|
105
|
+
* 'get' on proxy: property 'getAccount' is a read-only and non-configurable
|
|
106
|
+
* data property on the proxy target but the proxy did not return its actual
|
|
107
|
+
* value
|
|
108
|
+
*
|
|
109
|
+
* That is a Proxy invariant, not a bug in the trap. `api` is an ES module
|
|
110
|
+
* namespace object, and a bundler is free to emit its exports as non-writable and
|
|
111
|
+
* non-configurable — Next's production build does, its dev server does not. When
|
|
112
|
+
* a target property is a read-only non-configurable data property, `get` **must**
|
|
113
|
+
* return that exact value, so a trap whose entire purpose is to return a wrapper
|
|
114
|
+
* cannot be correct. The old code was not wrong about the bundler; it was wrong
|
|
115
|
+
* about Proxy.
|
|
116
|
+
*
|
|
117
|
+
* It failed the worst possible way: every local check passes, `pnpm dev` passes,
|
|
118
|
+
* the production bundle throws on the first call. In the console that first call
|
|
119
|
+
* is `getAccount` during sign-in, so the symptom was "nobody can log in" with an
|
|
120
|
+
* error naming IAM — a service that was fine.
|
|
121
|
+
*
|
|
122
|
+
* Copying costs one pass over a few dozen keys per client. Clients are made per
|
|
123
|
+
* request here, which sounds like a lot until you notice the request that follows
|
|
124
|
+
* goes over a network.
|
|
99
125
|
*/
|
|
100
126
|
export declare function bindClient<T extends object>(api: T, client: Client): Bound<T>;
|
package/dist/http.js
CHANGED
|
@@ -83,23 +83,56 @@ export async function request(config, options) {
|
|
|
83
83
|
* `scripts/check-generated-arity.mjs` fails the build if that changes: a slot
|
|
84
84
|
* that silently shifts by one would pass the client as somebody's request body,
|
|
85
85
|
* and no amount of type checking on generated code would catch it.
|
|
86
|
+
*
|
|
87
|
+
* # Why this builds an object instead of returning a Proxy
|
|
88
|
+
*
|
|
89
|
+
* It used to be a `Proxy` over the namespace, which is smaller and binds lazily.
|
|
90
|
+
* It also threw, in production only:
|
|
91
|
+
*
|
|
92
|
+
* 'get' on proxy: property 'getAccount' is a read-only and non-configurable
|
|
93
|
+
* data property on the proxy target but the proxy did not return its actual
|
|
94
|
+
* value
|
|
95
|
+
*
|
|
96
|
+
* That is a Proxy invariant, not a bug in the trap. `api` is an ES module
|
|
97
|
+
* namespace object, and a bundler is free to emit its exports as non-writable and
|
|
98
|
+
* non-configurable — Next's production build does, its dev server does not. When
|
|
99
|
+
* a target property is a read-only non-configurable data property, `get` **must**
|
|
100
|
+
* return that exact value, so a trap whose entire purpose is to return a wrapper
|
|
101
|
+
* cannot be correct. The old code was not wrong about the bundler; it was wrong
|
|
102
|
+
* about Proxy.
|
|
103
|
+
*
|
|
104
|
+
* It failed the worst possible way: every local check passes, `pnpm dev` passes,
|
|
105
|
+
* the production bundle throws on the first call. In the console that first call
|
|
106
|
+
* is `getAccount` during sign-in, so the symptom was "nobody can log in" with an
|
|
107
|
+
* error naming IAM — a service that was fine.
|
|
108
|
+
*
|
|
109
|
+
* Copying costs one pass over a few dozen keys per client. Clients are made per
|
|
110
|
+
* request here, which sounds like a lot until you notice the request that follows
|
|
111
|
+
* goes over a network.
|
|
86
112
|
*/
|
|
87
113
|
export function bindClient(api, client) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
114
|
+
const bound = {};
|
|
115
|
+
/*
|
|
116
|
+
* `for...in` rather than `Object.keys`: a namespace object's exports are its
|
|
117
|
+
* own enumerable properties either way, but re-exported members can arrive on
|
|
118
|
+
* the prototype chain depending on how the bundler emitted them, and an
|
|
119
|
+
* operation that is silently missing is worse than one that is bound twice.
|
|
120
|
+
*/
|
|
121
|
+
for (const property in api) {
|
|
122
|
+
const value = api[property];
|
|
123
|
+
if (typeof value !== 'function') {
|
|
124
|
+
bound[property] = value;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const operation = value;
|
|
128
|
+
bound[property] = (...args) => {
|
|
129
|
+
const slot = Math.max(operation.length - 1, 0);
|
|
130
|
+
const head = args.slice(0, slot);
|
|
131
|
+
while (head.length < slot) {
|
|
132
|
+
head.push(undefined);
|
|
93
133
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
while (head.length < slot) {
|
|
99
|
-
head.push(undefined);
|
|
100
|
-
}
|
|
101
|
-
return operation(...head, { client });
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
});
|
|
134
|
+
return operation(...head, { client });
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return bound;
|
|
105
138
|
}
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ export function createMonitoringClient(options) {
|
|
|
61
61
|
/** Service versions the bundled specs were generated from. */
|
|
62
62
|
export const SERVICE_VERSIONS = {
|
|
63
63
|
assistant: "v2.2.0",
|
|
64
|
-
compute: "v2.
|
|
64
|
+
compute: "v2.7.0",
|
|
65
65
|
iam: "v0.32.0",
|
|
66
66
|
monitoring: "v9.2.0",
|
|
67
67
|
};
|
package/openapi/compute.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v2.
|
|
1
|
+
v2.7.0
|