@scrapyio/sdk 0.1.0 → 0.1.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/pagination.d.ts.map +1 -1
- package/dist/pagination.js +36 -4
- package/dist/pagination.js.map +1 -1
- package/package.json +4 -3
package/dist/pagination.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI;IACpB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,EAAE,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAMF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAsB5E;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAgB1D"}
|
package/dist/pagination.js
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
|
+
import { ScrapyIOError } from './errors.js';
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
1
5
|
export function unwrapCollection(envelope) {
|
|
6
|
+
if (!isPlainObject(envelope)) {
|
|
7
|
+
throw new ScrapyIOError({
|
|
8
|
+
message: 'Invalid collection response envelope',
|
|
9
|
+
type: 'internal_error',
|
|
10
|
+
body: envelope,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
2
13
|
const data = envelope.data;
|
|
14
|
+
if (!isPlainObject(data)) {
|
|
15
|
+
throw new ScrapyIOError({
|
|
16
|
+
message: 'Invalid collection response data',
|
|
17
|
+
type: 'internal_error',
|
|
18
|
+
body: envelope,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
3
21
|
return {
|
|
4
|
-
items: data.items
|
|
5
|
-
total: data.total
|
|
6
|
-
offset: data.offset
|
|
7
|
-
limit: data.limit
|
|
22
|
+
items: Array.isArray(data.items) ? data.items : [],
|
|
23
|
+
total: typeof data.total === 'number' ? data.total : 0,
|
|
24
|
+
offset: typeof data.offset === 'number' ? data.offset : 0,
|
|
25
|
+
limit: typeof data.limit === 'number' ? data.limit : 0,
|
|
8
26
|
};
|
|
9
27
|
}
|
|
10
28
|
export function unwrapData(envelope) {
|
|
29
|
+
if (!isPlainObject(envelope) || !('data' in envelope)) {
|
|
30
|
+
throw new ScrapyIOError({
|
|
31
|
+
message: 'Invalid response envelope',
|
|
32
|
+
type: 'internal_error',
|
|
33
|
+
body: envelope,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (envelope.data === null || envelope.data === undefined) {
|
|
37
|
+
throw new ScrapyIOError({
|
|
38
|
+
message: 'Invalid response data',
|
|
39
|
+
type: 'internal_error',
|
|
40
|
+
body: envelope,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
11
43
|
return envelope.data;
|
|
12
44
|
}
|
|
13
45
|
//# sourceMappingURL=pagination.js.map
|
package/dist/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"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AAC,CAAC,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,QAAyB;IACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EAAE,2BAA2B;YACpC,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1D,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EAAE,uBAAuB;YAChC,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrapyio/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for the Scrapy.io Platform API and publisher execution APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
"lint:openapi": "npx --yes @redocly/cli@1.34.3 lint ../../docsscrapyio/openapi/platform-v1.yaml",
|
|
21
21
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
22
|
"build": "tsc -p tsconfig.json",
|
|
23
|
-
"test": "node --import tsx --test \"test/sdk.test.ts\"",
|
|
23
|
+
"test": "node --import tsx --test \"test/auth.test.ts\" \"test/tools.test.ts\" \"test/execution.test.ts\" \"test/runs.test.ts\" \"test/wait.test.ts\" \"test/schedules.test.ts\" \"test/retries.test.ts\" \"test/errors.test.ts\" \"test/contract.test.ts\" \"test/sdk.test.ts\"",
|
|
24
24
|
"test:integration": "node --import tsx --test \"test/integration.test.ts\"",
|
|
25
25
|
"check": "npm run lint:openapi && npm run generate && npm run typecheck && npm run test",
|
|
26
26
|
"bootstrap:env": "npx tsx scripts/bootstrap-integration-env.ts",
|
|
27
|
-
"pack:dry": "npm run build && npm pack --dry-run"
|
|
27
|
+
"pack:dry": "npm run build && npm pack --dry-run",
|
|
28
|
+
"release:validate": "node --import tsx scripts/release-validate.mjs"
|
|
28
29
|
},
|
|
29
30
|
"engines": {
|
|
30
31
|
"node": ">=18"
|