deepline 0.2.3 → 0.2.4
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/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/opensosdata-batching.ts +182 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -160,7 +160,7 @@ export const SDK_RELEASE = {
|
|
|
160
160
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
161
161
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
162
162
|
// release keeps lazy paging semantics independent of row residency.
|
|
163
|
-
version: '0.2.
|
|
163
|
+
version: '0.2.4',
|
|
164
164
|
contracts: {
|
|
165
165
|
api: {
|
|
166
166
|
name: 'sdk-http-api',
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineBatchStrategyMap,
|
|
3
|
+
type BatchOperationStrategy,
|
|
4
|
+
} from './batching-types';
|
|
5
|
+
|
|
6
|
+
type OpenSosDataScalarPayload = Record<string, unknown> & {
|
|
7
|
+
entity_name: string;
|
|
8
|
+
state: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type OpenSosDataBulkPayload = Record<string, unknown> & {
|
|
12
|
+
entities: Array<{ entity_name: string; state: string }>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type OpenSosDataBulkResultRow = Record<string, unknown> & {
|
|
16
|
+
entity_name?: string;
|
|
17
|
+
state?: string;
|
|
18
|
+
success?: boolean;
|
|
19
|
+
data?: unknown;
|
|
20
|
+
error?: string | null;
|
|
21
|
+
cost?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type OpenSosDataBulkResult = Record<string, unknown> & {
|
|
25
|
+
job_id?: string;
|
|
26
|
+
status?: string;
|
|
27
|
+
polling_interrupted?: boolean;
|
|
28
|
+
polling_timed_out?: boolean;
|
|
29
|
+
recovery_operation?: string;
|
|
30
|
+
results?: OpenSosDataBulkResultRow[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function normalizeEntityName(value: unknown): string {
|
|
34
|
+
return String(value ?? '')
|
|
35
|
+
.trim()
|
|
36
|
+
.replace(/\s+/g, ' ')
|
|
37
|
+
.toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function normalizeState(value: unknown): string {
|
|
41
|
+
return String(value ?? '')
|
|
42
|
+
.trim()
|
|
43
|
+
.toUpperCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function correlationKey(input: {
|
|
47
|
+
entity_name?: unknown;
|
|
48
|
+
state?: unknown;
|
|
49
|
+
}): string {
|
|
50
|
+
return JSON.stringify([
|
|
51
|
+
normalizeEntityName(input.entity_name),
|
|
52
|
+
normalizeState(input.state),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function requireResultIdentity(row: OpenSosDataBulkResultRow): string {
|
|
57
|
+
if (
|
|
58
|
+
typeof row.entity_name !== 'string' ||
|
|
59
|
+
!row.entity_name.trim() ||
|
|
60
|
+
typeof row.state !== 'string' ||
|
|
61
|
+
!row.state.trim()
|
|
62
|
+
) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
'OpenSOSData bulk result is missing entity_name/state correlation identity.',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return correlationKey(row);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function toScalarResult(
|
|
71
|
+
row: OpenSosDataBulkResultRow,
|
|
72
|
+
): Record<string, unknown> {
|
|
73
|
+
const scalarResult: Record<string, unknown> = { ...row };
|
|
74
|
+
delete scalarResult.entity_name;
|
|
75
|
+
delete scalarResult.state;
|
|
76
|
+
if (typeof scalarResult.success !== 'boolean') {
|
|
77
|
+
scalarResult.success = row.data !== undefined;
|
|
78
|
+
}
|
|
79
|
+
return scalarResult;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const opensosDataBusinessLookupBatchStrategy: BatchOperationStrategy<
|
|
83
|
+
OpenSosDataScalarPayload,
|
|
84
|
+
OpenSosDataBulkPayload,
|
|
85
|
+
OpenSosDataBulkResult,
|
|
86
|
+
Record<string, unknown>,
|
|
87
|
+
OpenSosDataBulkResultRow
|
|
88
|
+
> = {
|
|
89
|
+
sourceOperation: 'opensosdata_business_lookup',
|
|
90
|
+
batchOperation: 'opensosdata_bulk_lookup',
|
|
91
|
+
kind: 'identifier_batch',
|
|
92
|
+
maxBatchSize: 256,
|
|
93
|
+
canBatchWith() {
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
toBucketKey() {
|
|
97
|
+
return 'opensosdata_bulk_lookup';
|
|
98
|
+
},
|
|
99
|
+
toItemKey(payload) {
|
|
100
|
+
return correlationKey(payload);
|
|
101
|
+
},
|
|
102
|
+
compile(payloads) {
|
|
103
|
+
return {
|
|
104
|
+
batchOperation: 'opensosdata_bulk_lookup',
|
|
105
|
+
batchPayload: {
|
|
106
|
+
entities: payloads.map((payload) => ({
|
|
107
|
+
entity_name: payload.entity_name,
|
|
108
|
+
state: payload.state,
|
|
109
|
+
})),
|
|
110
|
+
},
|
|
111
|
+
items: payloads.map((payload) => ({
|
|
112
|
+
itemKey: correlationKey(payload),
|
|
113
|
+
payload,
|
|
114
|
+
})),
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
splitResult(fullResult, compiled) {
|
|
118
|
+
if (
|
|
119
|
+
typeof fullResult.job_id === 'string' &&
|
|
120
|
+
(fullResult.status === 'queued' || fullResult.status === 'processing')
|
|
121
|
+
) {
|
|
122
|
+
return compiled.items.map((item) => ({
|
|
123
|
+
itemKey: item.itemKey,
|
|
124
|
+
result: {
|
|
125
|
+
job_id: fullResult.job_id,
|
|
126
|
+
status: fullResult.status,
|
|
127
|
+
polling_interrupted: fullResult.polling_interrupted === true,
|
|
128
|
+
polling_timed_out: fullResult.polling_timed_out === true,
|
|
129
|
+
recovery_operation:
|
|
130
|
+
fullResult.recovery_operation ?? 'opensosdata_get_bulk_result',
|
|
131
|
+
},
|
|
132
|
+
rawResult: fullResult,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(fullResult.results)) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
'OpenSOSData completed bulk result is missing its results array.',
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const remainingByKey = new Map<string, number>();
|
|
142
|
+
for (const item of compiled.items) {
|
|
143
|
+
remainingByKey.set(
|
|
144
|
+
item.itemKey,
|
|
145
|
+
(remainingByKey.get(item.itemKey) ?? 0) + 1,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const rowsByKey = new Map<string, OpenSosDataBulkResultRow[]>();
|
|
150
|
+
for (const row of fullResult.results) {
|
|
151
|
+
const key = requireResultIdentity(row);
|
|
152
|
+
const remaining = remainingByKey.get(key) ?? 0;
|
|
153
|
+
if (remaining < 1) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`OpenSOSData bulk result has unmatched correlation identity ${key}.`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
remainingByKey.set(key, remaining - 1);
|
|
159
|
+
const rows = rowsByKey.get(key);
|
|
160
|
+
if (rows) rows.push(row);
|
|
161
|
+
else rowsByKey.set(key, [row]);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return compiled.items.map((item) => {
|
|
165
|
+
const row = rowsByKey.get(item.itemKey)?.shift();
|
|
166
|
+
if (!row) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`OpenSOSData bulk result is missing result identity ${item.itemKey}.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
itemKey: item.itemKey,
|
|
173
|
+
result: toScalarResult(row),
|
|
174
|
+
rawResult: row,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const opensosdataBatchStrategies = defineBatchStrategyMap({
|
|
181
|
+
opensosdata_business_lookup: opensosDataBusinessLookupBatchStrategy,
|
|
182
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AnyBatchOperationStrategy } from './batching-types';
|
|
2
2
|
import { DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES } from './default-batch-strategies';
|
|
3
3
|
import { fullenrichBatchStrategies } from './fullenrich-batching';
|
|
4
|
+
import { opensosdataBatchStrategies } from './opensosdata-batching';
|
|
4
5
|
|
|
5
6
|
export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
|
|
6
7
|
string,
|
|
@@ -8,6 +9,7 @@ export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
|
|
|
8
9
|
> = {
|
|
9
10
|
...DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES,
|
|
10
11
|
...fullenrichBatchStrategies,
|
|
12
|
+
...opensosdataBatchStrategies,
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export function getPlayRuntimeBatchStrategy(
|
package/dist/cli/index.js
CHANGED
|
@@ -1040,7 +1040,7 @@ var SDK_RELEASE = {
|
|
|
1040
1040
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
1041
1041
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
1042
1042
|
// release keeps lazy paging semantics independent of row residency.
|
|
1043
|
-
version: "0.2.
|
|
1043
|
+
version: "0.2.4",
|
|
1044
1044
|
contracts: {
|
|
1045
1045
|
api: {
|
|
1046
1046
|
name: "sdk-http-api",
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1025,7 +1025,7 @@ var SDK_RELEASE = {
|
|
|
1025
1025
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
1026
1026
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
1027
1027
|
// release keeps lazy paging semantics independent of row residency.
|
|
1028
|
-
version: "0.2.
|
|
1028
|
+
version: "0.2.4",
|
|
1029
1029
|
contracts: {
|
|
1030
1030
|
api: {
|
|
1031
1031
|
name: "sdk-http-api",
|
package/dist/index.js
CHANGED
|
@@ -763,7 +763,7 @@ var SDK_RELEASE = {
|
|
|
763
763
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
764
764
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
765
765
|
// release keeps lazy paging semantics independent of row residency.
|
|
766
|
-
version: "0.2.
|
|
766
|
+
version: "0.2.4",
|
|
767
767
|
contracts: {
|
|
768
768
|
api: {
|
|
769
769
|
name: "sdk-http-api",
|
package/dist/index.mjs
CHANGED
|
@@ -689,7 +689,7 @@ var SDK_RELEASE = {
|
|
|
689
689
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
690
690
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
691
691
|
// release keeps lazy paging semantics independent of row residency.
|
|
692
|
-
version: "0.2.
|
|
692
|
+
version: "0.2.4",
|
|
693
693
|
contracts: {
|
|
694
694
|
api: {
|
|
695
695
|
name: "sdk-http-api",
|