@lessly/sdk-app 48.0.3 → 49.0.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/dist/analytics/index.d.cts +1 -1
- package/dist/analytics/index.d.ts +1 -1
- package/dist/brain/index.d.cts +1 -1
- package/dist/brain/index.d.ts +1 -1
- package/dist/{client.gen-DqvpKriz.d.cts → client.gen-CLRsCNvG.d.cts} +1 -217
- package/dist/{client.gen-DqvpKriz.d.ts → client.gen-CLRsCNvG.d.ts} +1 -217
- package/dist/consent/index.d.cts +1 -1
- package/dist/consent/index.d.ts +1 -1
- package/dist/content/index.d.cts +1 -1
- package/dist/content/index.d.ts +1 -1
- package/dist/deployment/index.d.cts +1 -1
- package/dist/deployment/index.d.ts +1 -1
- package/dist/index.cjs +67 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -3
- package/dist/index.d.ts +72 -3
- package/dist/index.js +67 -105
- package/dist/index.js.map +1 -1
- package/dist/mail/index.d.cts +2 -2
- package/dist/mail/index.d.ts +2 -2
- package/dist/observe/index.d.cts +1 -1
- package/dist/observe/index.d.ts +1 -1
- package/dist/organization/index.d.cts +1 -1
- package/dist/organization/index.d.ts +1 -1
- package/dist/realtime/index.d.cts +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/support/index.d.cts +1 -1
- package/dist/support/index.d.ts +1 -1
- package/dist/tracking/index.d.cts +1 -1
- package/dist/tracking/index.d.ts +1 -1
- package/dist/users/index.d.cts +1 -1
- package/dist/users/index.d.ts +1 -1
- package/dist/waitlist/index.d.cts +1 -1
- package/dist/waitlist/index.d.ts +1 -1
- package/docs/recipes/sdk-usage.md +50 -0
- package/docs/rules.md +13 -0
- package/package.json +2 -7
- package/src/gen/bindings.gen.ts +3 -105
- package/src/gen/client.gen.ts +0 -52
- package/src/gen/manifest.gen.ts +1 -1
- package/src/gen/types.gen.ts +0 -220
- package/dist/playground/index.cjs +0 -66
- package/dist/playground/index.cjs.map +0 -1
- package/dist/playground/index.d.cts +0 -52
- package/dist/playground/index.d.ts +0 -52
- package/dist/playground/index.js +0 -53
- package/dist/playground/index.js.map +0 -1
- package/src/gen/playground/index.ts +0 -3
- package/src/gen/playground/queryOptions.gen.ts +0 -86
package/dist/index.cjs
CHANGED
|
@@ -126,6 +126,65 @@ async function executeRequest(opts, binding, input) {
|
|
|
126
126
|
return parsed;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
// src/runtime/connectStream.ts
|
|
130
|
+
function toWsUrl(url) {
|
|
131
|
+
if (url.startsWith("https:")) return `wss:${url.slice("https:".length)}`;
|
|
132
|
+
if (url.startsWith("http:")) return `ws:${url.slice("http:".length)}`;
|
|
133
|
+
return url;
|
|
134
|
+
}
|
|
135
|
+
function connectStream(opts, binding, input) {
|
|
136
|
+
const restLike = { method: "GET", path: binding.path, ...binding.params ? { params: binding.params } : {} };
|
|
137
|
+
const { path, query, body } = resolveRequest(restLike, input);
|
|
138
|
+
const url = toWsUrl(buildUrl(opts.baseUrl, path, { ...query, ...body ?? {} }));
|
|
139
|
+
const Ctor = opts.WebSocket ?? globalThis.WebSocket;
|
|
140
|
+
if (!Ctor) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`@lessly/sdk-app: WebSocket is unavailable in this environment, so the stream to "${binding.path}" cannot be opened. Streaming requires a browser; pass options.WebSocket to supply an implementation.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const socket = new Ctor(url);
|
|
146
|
+
const messageSubs = /* @__PURE__ */ new Set();
|
|
147
|
+
const closeSubs = /* @__PURE__ */ new Set();
|
|
148
|
+
let pending = [];
|
|
149
|
+
socket.addEventListener("open", () => {
|
|
150
|
+
const queued = pending ?? [];
|
|
151
|
+
pending = null;
|
|
152
|
+
for (const frame of queued) socket.send(frame);
|
|
153
|
+
});
|
|
154
|
+
socket.addEventListener("message", (ev) => {
|
|
155
|
+
for (const cb of [...messageSubs]) cb(ev.data);
|
|
156
|
+
});
|
|
157
|
+
socket.addEventListener("close", (ev) => {
|
|
158
|
+
pending = null;
|
|
159
|
+
const info = { code: ev.code ?? 1006, reason: ev.reason ?? "", wasClean: ev.wasClean ?? false };
|
|
160
|
+
for (const cb of [...closeSubs]) cb(info);
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
send(data) {
|
|
164
|
+
if (pending !== null) {
|
|
165
|
+
pending.push(data);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (socket.readyState === 1) socket.send(data);
|
|
169
|
+
},
|
|
170
|
+
close(code, reason) {
|
|
171
|
+
pending = null;
|
|
172
|
+
socket.close(code, reason);
|
|
173
|
+
},
|
|
174
|
+
onMessage(cb) {
|
|
175
|
+
messageSubs.add(cb);
|
|
176
|
+
return () => messageSubs.delete(cb);
|
|
177
|
+
},
|
|
178
|
+
onClose(cb) {
|
|
179
|
+
closeSubs.add(cb);
|
|
180
|
+
return () => closeSubs.delete(cb);
|
|
181
|
+
},
|
|
182
|
+
get readyState() {
|
|
183
|
+
return socket.readyState;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
129
188
|
// src/runtime/name.ts
|
|
130
189
|
var ROOT_RESOURCE = "$root";
|
|
131
190
|
function splitToolName(name) {
|
|
@@ -5809,110 +5868,6 @@ var bindings = {
|
|
|
5809
5868
|
}
|
|
5810
5869
|
}
|
|
5811
5870
|
},
|
|
5812
|
-
"playground": {
|
|
5813
|
-
"analytics": {
|
|
5814
|
-
"overview": {
|
|
5815
|
-
"method": "POST",
|
|
5816
|
-
"params": [
|
|
5817
|
-
{
|
|
5818
|
-
"in": "body",
|
|
5819
|
-
"name": "limit"
|
|
5820
|
-
}
|
|
5821
|
-
],
|
|
5822
|
-
"path": "/playground/analytics/overview",
|
|
5823
|
-
"readOnly": true
|
|
5824
|
-
}
|
|
5825
|
-
},
|
|
5826
|
-
"billing": {
|
|
5827
|
-
"entitlements": {
|
|
5828
|
-
"method": "POST",
|
|
5829
|
-
"path": "/playground/billing/entitlements",
|
|
5830
|
-
"readOnly": true
|
|
5831
|
-
},
|
|
5832
|
-
"record-usage": {
|
|
5833
|
-
"method": "POST",
|
|
5834
|
-
"params": [
|
|
5835
|
-
{
|
|
5836
|
-
"in": "body",
|
|
5837
|
-
"name": "value"
|
|
5838
|
-
}
|
|
5839
|
-
],
|
|
5840
|
-
"path": "/playground/billing/usage",
|
|
5841
|
-
"readOnly": false
|
|
5842
|
-
}
|
|
5843
|
-
},
|
|
5844
|
-
"clickup": {
|
|
5845
|
-
"create-task": {
|
|
5846
|
-
"method": "POST",
|
|
5847
|
-
"params": [
|
|
5848
|
-
{
|
|
5849
|
-
"in": "body",
|
|
5850
|
-
"name": "listId"
|
|
5851
|
-
},
|
|
5852
|
-
{
|
|
5853
|
-
"in": "body",
|
|
5854
|
-
"name": "name"
|
|
5855
|
-
}
|
|
5856
|
-
],
|
|
5857
|
-
"path": "/playground/clickup/tasks",
|
|
5858
|
-
"readOnly": false
|
|
5859
|
-
},
|
|
5860
|
-
"get-last-webhook": {
|
|
5861
|
-
"method": "GET",
|
|
5862
|
-
"path": "/playground/clickup/webhooks/last",
|
|
5863
|
-
"readOnly": true
|
|
5864
|
-
},
|
|
5865
|
-
"get-overview": {
|
|
5866
|
-
"method": "GET",
|
|
5867
|
-
"path": "/playground/clickup/overview",
|
|
5868
|
-
"readOnly": true
|
|
5869
|
-
}
|
|
5870
|
-
},
|
|
5871
|
-
"gdrive": {
|
|
5872
|
-
"get-last-change": {
|
|
5873
|
-
"method": "GET",
|
|
5874
|
-
"path": "/playground/gdrive/changes/last",
|
|
5875
|
-
"readOnly": true
|
|
5876
|
-
},
|
|
5877
|
-
"read-file": {
|
|
5878
|
-
"method": "POST",
|
|
5879
|
-
"params": [
|
|
5880
|
-
{
|
|
5881
|
-
"in": "body",
|
|
5882
|
-
"name": "fileId"
|
|
5883
|
-
}
|
|
5884
|
-
],
|
|
5885
|
-
"path": "/playground/gdrive/file",
|
|
5886
|
-
"readOnly": true
|
|
5887
|
-
}
|
|
5888
|
-
},
|
|
5889
|
-
"googleads": {
|
|
5890
|
-
"read-customer": {
|
|
5891
|
-
"method": "POST",
|
|
5892
|
-
"path": "/playground/googleads/customer",
|
|
5893
|
-
"readOnly": true
|
|
5894
|
-
}
|
|
5895
|
-
},
|
|
5896
|
-
"lifecycle": {
|
|
5897
|
-
"get-state": {
|
|
5898
|
-
"method": "GET",
|
|
5899
|
-
"path": "/playground/lifecycle/state",
|
|
5900
|
-
"readOnly": true
|
|
5901
|
-
},
|
|
5902
|
-
"list-events": {
|
|
5903
|
-
"method": "GET",
|
|
5904
|
-
"path": "/playground/lifecycle/events",
|
|
5905
|
-
"readOnly": true
|
|
5906
|
-
}
|
|
5907
|
-
},
|
|
5908
|
-
"webhook": {
|
|
5909
|
-
"get-last": {
|
|
5910
|
-
"method": "GET",
|
|
5911
|
-
"path": "/playground/webhooks/last",
|
|
5912
|
-
"readOnly": true
|
|
5913
|
-
}
|
|
5914
|
-
}
|
|
5915
|
-
},
|
|
5916
5871
|
"realtime": {
|
|
5917
5872
|
"archive": {
|
|
5918
5873
|
"export": {
|
|
@@ -8805,6 +8760,13 @@ function createLesslyApp(opts) {
|
|
|
8805
8760
|
const map = bindings;
|
|
8806
8761
|
const nsCache = {};
|
|
8807
8762
|
const base = {
|
|
8763
|
+
// The whole streaming surface of the client. Streams are NOT reachable through the request
|
|
8764
|
+
// proxy: a socket is not a promise-returning call, and hanging one off `sdk.<ns>.<res>.<act>`
|
|
8765
|
+
// would make two very different lifetimes look identical at the call site. The generated
|
|
8766
|
+
// `<tool>Connect` factories carry the binding and call this.
|
|
8767
|
+
openStream(binding, input) {
|
|
8768
|
+
return connectStream(opts, binding, input);
|
|
8769
|
+
},
|
|
8808
8770
|
call(toolName, input) {
|
|
8809
8771
|
let split;
|
|
8810
8772
|
try {
|
|
@@ -8830,6 +8792,7 @@ function createLesslyApp(opts) {
|
|
|
8830
8792
|
}
|
|
8831
8793
|
|
|
8832
8794
|
exports.LesslyApiError = LesslyApiError;
|
|
8795
|
+
exports.connectStream = connectStream;
|
|
8833
8796
|
exports.createLesslyApp = createLesslyApp;
|
|
8834
8797
|
//# sourceMappingURL=index.cjs.map
|
|
8835
8798
|
//# sourceMappingURL=index.cjs.map
|