@opendatalabs/personal-server-ts-core 1.25.0 → 1.26.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/legacy-projection/bindings.d.ts +10 -0
- package/dist/legacy-projection/bindings.d.ts.map +1 -0
- package/dist/legacy-projection/bindings.js +3945 -0
- package/dist/legacy-projection/bindings.js.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.js +128 -0
- package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/index.d.ts +33 -0
- package/dist/legacy-projection/index.d.ts.map +1 -0
- package/dist/legacy-projection/index.js +189 -0
- package/dist/legacy-projection/index.js.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.js +112 -0
- package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.js +137 -0
- package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/provenance.d.ts +57 -0
- package/dist/legacy-projection/provenance.d.ts.map +1 -0
- package/dist/legacy-projection/provenance.js +2 -0
- package/dist/legacy-projection/provenance.js.map +1 -0
- package/dist/legacy-projection/test-debris.d.ts +2 -0
- package/dist/legacy-projection/test-debris.d.ts.map +1 -0
- package/dist/legacy-projection/test-debris.js +49 -0
- package/dist/legacy-projection/test-debris.js.map +1 -0
- package/dist/legacy-projection/types.d.ts +167 -0
- package/dist/legacy-projection/types.d.ts.map +1 -0
- package/dist/legacy-projection/types.js +2 -0
- package/dist/legacy-projection/types.js.map +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-040-bindings.d.ts","sourceRoot":"","sources":["../../src/legacy-projection/meta-040-bindings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAC;AAkHvE,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAsBnE,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { LEGACY_SCOPE_BINDINGS } from "./bindings.js";
|
|
2
|
+
const source = "https://registry.pdpp.dev/connectors/meta";
|
|
3
|
+
const manifestDigest = "sha256:2340917b44ca61f0d4ab947fcd6dbac90103329b7d40ed5fb1a815248483f5fb";
|
|
4
|
+
const sourceRevision = "PDP-Connect/data-connectors@c03818f6ad733f90980784274e3eb4e90a168009";
|
|
5
|
+
const original = LEGACY_SCOPE_BINDINGS.get("instagram.posts");
|
|
6
|
+
if (!original)
|
|
7
|
+
throw new Error("Missing retained Instagram posts binding");
|
|
8
|
+
const instagramPosts040 = {
|
|
9
|
+
...original,
|
|
10
|
+
pdppSource: source,
|
|
11
|
+
fieldsRead: {
|
|
12
|
+
...original.fieldsRead,
|
|
13
|
+
post_likes: [
|
|
14
|
+
"post_id",
|
|
15
|
+
"liker_ordinal",
|
|
16
|
+
"user_id",
|
|
17
|
+
"username",
|
|
18
|
+
"profile_pic_url",
|
|
19
|
+
"pk",
|
|
20
|
+
"id",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
primaryKey: { posts: ["id"], post_likes: ["post_id", "liker_ordinal"] },
|
|
24
|
+
lossy: original.lossy.filter((item) => !item.startsWith("who_liked.profile_pic_url") &&
|
|
25
|
+
!item.startsWith("who_liked.pk")),
|
|
26
|
+
project(records, options) {
|
|
27
|
+
const invalidLiker = records.some((record) => record.stream === "post_likes" &&
|
|
28
|
+
(!Number.isInteger(record.data.liker_ordinal) ||
|
|
29
|
+
record.data.liker_ordinal < 0));
|
|
30
|
+
if (invalidLiker) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
error: {
|
|
34
|
+
kind: "incomplete_scope",
|
|
35
|
+
scope: "instagram.posts",
|
|
36
|
+
reason: "post_likes record lacks a valid liker ordinal",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const projected = original.project(records, options);
|
|
41
|
+
if (!projected.ok)
|
|
42
|
+
return projected;
|
|
43
|
+
const likesByPost = new Map();
|
|
44
|
+
for (const record of records) {
|
|
45
|
+
if (record.stream !== "post_likes")
|
|
46
|
+
continue;
|
|
47
|
+
const liker = record.data;
|
|
48
|
+
if (typeof liker.post_id !== "string" ||
|
|
49
|
+
typeof liker.user_id !== "string" ||
|
|
50
|
+
typeof liker.username !== "string") {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const id = (typeof liker.id === "string" && liker.id) ||
|
|
54
|
+
(typeof liker.pk === "string" && liker.pk) ||
|
|
55
|
+
liker.user_id;
|
|
56
|
+
const whoLiked = likesByPost.get(liker.post_id) ?? [];
|
|
57
|
+
whoLiked.push({
|
|
58
|
+
ordinal: liker.liker_ordinal,
|
|
59
|
+
value: {
|
|
60
|
+
profile_pic_url: typeof liker.profile_pic_url === "string"
|
|
61
|
+
? liker.profile_pic_url
|
|
62
|
+
: "",
|
|
63
|
+
pk: (typeof liker.pk === "string" && liker.pk) ||
|
|
64
|
+
(typeof liker.id === "string" && liker.id) ||
|
|
65
|
+
id,
|
|
66
|
+
username: liker.username,
|
|
67
|
+
id: (typeof liker.id === "string" && liker.id) ||
|
|
68
|
+
(typeof liker.pk === "string" && liker.pk) ||
|
|
69
|
+
id,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
likesByPost.set(liker.post_id, whoLiked);
|
|
73
|
+
}
|
|
74
|
+
const sourcePosts = records.filter((record) => record.stream === "posts");
|
|
75
|
+
const posts = Array.isArray(projected.payload.posts)
|
|
76
|
+
? projected.payload.posts.map((post, index) => {
|
|
77
|
+
if (!post || typeof post !== "object" || Array.isArray(post))
|
|
78
|
+
return post;
|
|
79
|
+
const postId = sourcePosts[index]?.data.id;
|
|
80
|
+
return {
|
|
81
|
+
...post,
|
|
82
|
+
who_liked: typeof postId === "string"
|
|
83
|
+
? (likesByPost.get(postId) ?? [])
|
|
84
|
+
.sort((left, right) => left.ordinal - right.ordinal)
|
|
85
|
+
.map(({ value }) => value)
|
|
86
|
+
: [],
|
|
87
|
+
};
|
|
88
|
+
})
|
|
89
|
+
: projected.payload.posts;
|
|
90
|
+
return { ...projected, payload: { ...projected.payload, posts } };
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
export const META_040_BINDINGS = new Map([...LEGACY_SCOPE_BINDINGS]
|
|
94
|
+
.filter(([, binding]) => binding.pdppSource === source)
|
|
95
|
+
.map(([scope, binding]) => {
|
|
96
|
+
const profile = scope === "instagram.posts" ? instagramPosts040 : binding;
|
|
97
|
+
return [
|
|
98
|
+
scope,
|
|
99
|
+
{
|
|
100
|
+
...profile,
|
|
101
|
+
provenance: [
|
|
102
|
+
{
|
|
103
|
+
kind: "source-manifest",
|
|
104
|
+
ref: sourceRevision,
|
|
105
|
+
digest: manifestDigest,
|
|
106
|
+
path: `connectors/meta/manifest.json#streams[name=${profile.pdppStreams.join(",")}]`,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
}));
|
|
112
|
+
//# sourceMappingURL=meta-040-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-040-bindings.js","sourceRoot":"","sources":["../../src/legacy-projection/meta-040-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,GAAG,2CAA2C,CAAC;AAC3D,MAAM,cAAc,GAClB,yEAAyE,CAAC;AAC5E,MAAM,cAAc,GAClB,sEAAsE,CAAC;AAEzE,MAAM,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O,EAAE,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;IACpE,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,IAAI,GAAG,CACL,CAAC,GAAG,qBAAqB,CAAC;KACvB,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,KAAK,MAAM,CAAC;KACtD,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,EAAgC,EAAE;IACtD,MAAM,OAAO,GACX,KAAK,KAAK,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5D,OAAO;QACL,KAAK;QACL;YACE,GAAG,OAAO;YACV,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,iBAAiB;oBACvB,GAAG,EAAE,cAAc;oBACnB,MAAM,EAAE,cAAc;oBACtB,IAAI,EAAE,8CAA8C,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;iBACrF;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC,CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oura-browser-bindings.d.ts","sourceRoot":"","sources":["../../src/legacy-projection/oura-browser-bindings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAC;AAOvE,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAmKvE,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { LEGACY_SCOPE_BINDINGS } from "./bindings.js";
|
|
2
|
+
// Map signed Oura Browser 0.1.2 records into the retained legacy scopes.
|
|
3
|
+
const source = "https://registry.pdpp.dev/connectors/oura-browser";
|
|
4
|
+
const digest = "sha256:ddc901015996e4ae67030bcd9ec809aa368b1b69d94b8ed5515d1be0a886975d";
|
|
5
|
+
export const OURA_BROWSER_BINDINGS = new Map(["activity", "readiness", "sleep"].map((stream) => {
|
|
6
|
+
const scope = `oura.${stream}`;
|
|
7
|
+
const original = LEGACY_SCOPE_BINDINGS.get(scope);
|
|
8
|
+
if (!original)
|
|
9
|
+
throw new Error(`Missing retained Oura binding: ${scope}`);
|
|
10
|
+
return [
|
|
11
|
+
scope,
|
|
12
|
+
{
|
|
13
|
+
...original,
|
|
14
|
+
pdppSource: source,
|
|
15
|
+
fieldsRead: stream === "sleep"
|
|
16
|
+
? {
|
|
17
|
+
sleep: [
|
|
18
|
+
"record_type",
|
|
19
|
+
"id",
|
|
20
|
+
"day",
|
|
21
|
+
"sleep_score",
|
|
22
|
+
"daily_sleep_id",
|
|
23
|
+
"daily_sleep_timestamp",
|
|
24
|
+
"contributors",
|
|
25
|
+
"type",
|
|
26
|
+
"bedtime_start",
|
|
27
|
+
"bedtime_end",
|
|
28
|
+
"total_sleep_duration",
|
|
29
|
+
"time_in_bed",
|
|
30
|
+
"awake_time",
|
|
31
|
+
"deep_sleep_duration",
|
|
32
|
+
"light_sleep_duration",
|
|
33
|
+
"rem_sleep_duration",
|
|
34
|
+
"efficiency",
|
|
35
|
+
"latency",
|
|
36
|
+
"average_heart_rate",
|
|
37
|
+
"average_hrv",
|
|
38
|
+
"lowest_heart_rate",
|
|
39
|
+
"average_breath",
|
|
40
|
+
"restless_periods",
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
: original.fieldsRead,
|
|
44
|
+
lossy: stream === "sleep"
|
|
45
|
+
? original.lossy.filter((item) => !item.startsWith("awakeTime:") &&
|
|
46
|
+
!item.startsWith("dailyScores.timestamp:"))
|
|
47
|
+
: original.lossy,
|
|
48
|
+
provenance: [
|
|
49
|
+
{
|
|
50
|
+
kind: "oci",
|
|
51
|
+
ref: "ghcr.io/pdp-connect/connector/oura-browser:0.1.2",
|
|
52
|
+
digest,
|
|
53
|
+
path: `collection-profile.json#streams[name=${stream}]`,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
project(records, options) {
|
|
57
|
+
if (!options.fetchedStreams.includes(stream)) {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
error: {
|
|
61
|
+
kind: "missing_stream",
|
|
62
|
+
scope,
|
|
63
|
+
expectedStream: stream,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const streamRecords = records.filter((record) => record.stream === stream);
|
|
68
|
+
for (const { data } of streamRecords) {
|
|
69
|
+
if (typeof data.id !== "string" ||
|
|
70
|
+
!data.id.trim() ||
|
|
71
|
+
typeof data.day !== "string" ||
|
|
72
|
+
!/^\d{4}-\d{2}-\d{2}$/.test(data.day) ||
|
|
73
|
+
(stream === "sleep" &&
|
|
74
|
+
data.record_type !== "sleep_session" &&
|
|
75
|
+
data.record_type !== "daily_score")) {
|
|
76
|
+
return {
|
|
77
|
+
ok: false,
|
|
78
|
+
error: {
|
|
79
|
+
kind: "incomplete_scope",
|
|
80
|
+
scope,
|
|
81
|
+
reason: `${stream} record lacks a required retained field`,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (stream !== "sleep")
|
|
87
|
+
return original.project(records, options);
|
|
88
|
+
const sessions = streamRecords.filter(({ data }) => data.record_type === "sleep_session");
|
|
89
|
+
const scores = streamRecords.filter(({ data }) => data.record_type === "daily_score");
|
|
90
|
+
const sessionRecords = records.filter((record) => record.stream !== "sleep" ||
|
|
91
|
+
record.data.record_type === "sleep_session");
|
|
92
|
+
const projected = original.project(sessionRecords, options);
|
|
93
|
+
if (!projected.ok)
|
|
94
|
+
return projected;
|
|
95
|
+
const sessionById = new Map(sessions.map(({ data }) => [data.id, data]));
|
|
96
|
+
const sleepPeriods = Array.isArray(projected.payload.sleepPeriods)
|
|
97
|
+
? projected.payload.sleepPeriods.map((period) => {
|
|
98
|
+
if (!period ||
|
|
99
|
+
typeof period !== "object" ||
|
|
100
|
+
Array.isArray(period))
|
|
101
|
+
return period;
|
|
102
|
+
const sourceSession = sessionById.get(period.id);
|
|
103
|
+
if (!sourceSession ||
|
|
104
|
+
!(typeof sourceSession.awake_time === "number" ||
|
|
105
|
+
sourceSession.awake_time === null))
|
|
106
|
+
return period;
|
|
107
|
+
return {
|
|
108
|
+
...period,
|
|
109
|
+
awakeTime: sourceSession.awake_time,
|
|
110
|
+
};
|
|
111
|
+
})
|
|
112
|
+
: projected.payload.sleepPeriods;
|
|
113
|
+
const dailyScores = scores.map(({ data }) => ({
|
|
114
|
+
id: typeof data.daily_sleep_id === "string"
|
|
115
|
+
? data.daily_sleep_id
|
|
116
|
+
: data.id,
|
|
117
|
+
day: data.day,
|
|
118
|
+
...(typeof data.sleep_score === "number" ||
|
|
119
|
+
data.sleep_score === null
|
|
120
|
+
? { score: data.sleep_score }
|
|
121
|
+
: {}),
|
|
122
|
+
...(typeof data.daily_sleep_timestamp === "string"
|
|
123
|
+
? { timestamp: data.daily_sleep_timestamp }
|
|
124
|
+
: {}),
|
|
125
|
+
...(data.contributors && typeof data.contributors === "object"
|
|
126
|
+
? { contributors: data.contributors }
|
|
127
|
+
: {}),
|
|
128
|
+
}));
|
|
129
|
+
return {
|
|
130
|
+
...projected,
|
|
131
|
+
payload: { ...projected.payload, dailyScores, sleepPeriods },
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
}));
|
|
137
|
+
//# sourceMappingURL=oura-browser-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oura-browser-bindings.js","sourceRoot":"","sources":["../../src/legacy-projection/oura-browser-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,yEAAyE;AACzE,MAAM,MAAM,GAAG,mDAAmD,CAAC;AACnE,MAAM,MAAM,GACV,yEAAyE,CAAC;AAE5E,MAAM,CAAC,MA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AAS,CAAC,OAAO,CAAC,YAAY,CAAC;gBACnC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC5C,EAAE,EACA,OAAO,IAAI,CAAC,cAAc,KAAK,QAAQ;wBACrC,CAAC,CAAC,IAAI,CAAC,cAAc;wBACrB,CAAC,CAAC,IAAI,CAAC,EAAE;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,CAAC,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;wBACxC,IAAI,CAAC,WAAW,KAAK,IAAI;wBACvB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE;wBAC7B,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,OAAO,IAAI,CAAC,qBAAqB,KAAK,QAAQ;wBAChD,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,qBAAqB,EAAE;wBAC3C,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ;wBAC5D,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE;wBACrC,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC,CAAC,CAAC;gBACJ,OAAO;oBACL,GAAG,SAAS;oBACZ,OAAO,EAAE,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE;iBAC7D,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CACF,CACF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evidence provenance for a legacy-scope binding. No entry in the binding
|
|
3
|
+
* table may omit this — an entry with no resolvable provenance is a gap,
|
|
4
|
+
* per the brief, not a binding.
|
|
5
|
+
*
|
|
6
|
+
* - "oci": pulled live from ghcr.io/pdp-connect/connector/<name> via
|
|
7
|
+
* `oras pull`. `ref` is the OCI tag (human-readable, mutable); `digest` is
|
|
8
|
+
* the manifest digest captured at the same pull (`oras manifest fetch
|
|
9
|
+
* --descriptor`), the immutable pin a tag can be re-pushed away from. The
|
|
10
|
+
* connector-provenance.json digest inside that artifact (vendored
|
|
11
|
+
* alongside the collection-profile.json in
|
|
12
|
+
* ./declarations/<name>.provenance.json) names the exact data-connectors
|
|
13
|
+
* commit the artifact was built from.
|
|
14
|
+
* - "ps-fixture": vendored from vana-com/personal-server-ts test fixtures.
|
|
15
|
+
* These fixtures are themselves *copies of this repo's own prior output*
|
|
16
|
+
* (see declarations/README — PROVENANCE.md at the cited commit says so
|
|
17
|
+
* explicitly: producer repo unity-surfaces, PR #1098, commit bccc682e).
|
|
18
|
+
* Treat as corroboration of this repo's own history, not independent
|
|
19
|
+
* upstream confirmation.
|
|
20
|
+
* - "retired-descriptor": content from a data-connectors commit that has
|
|
21
|
+
* since been deleted upstream (PR #123, 2026-09-16, "retire the
|
|
22
|
+
* tarball-era PDPP Collection Profile descriptors"). Still real history,
|
|
23
|
+
* cited with its real hash, but not resolvable at HEAD and superseded by
|
|
24
|
+
* the OCI artifact path.
|
|
25
|
+
* - "collection-profile": immutable digest of the generated collection
|
|
26
|
+
* profile output. This pins the declaration bytes when the OCI manifest
|
|
27
|
+
* digest is not present in this checkout; it does not claim Desktop has
|
|
28
|
+
* admitted the connector or verified its signature at runtime.
|
|
29
|
+
* - "source-manifest": vendored source manifest bytes from an unpublished
|
|
30
|
+
* source worktree. The digest pins this adapter input but does not establish
|
|
31
|
+
* a published, signed collection profile.
|
|
32
|
+
*/
|
|
33
|
+
export type LegacyScopeBindingProvenance = {
|
|
34
|
+
digest: string;
|
|
35
|
+
kind: "oci";
|
|
36
|
+
path: string;
|
|
37
|
+
ref: string;
|
|
38
|
+
} | {
|
|
39
|
+
digest: string;
|
|
40
|
+
kind: "collection-profile";
|
|
41
|
+
path: string;
|
|
42
|
+
ref: string;
|
|
43
|
+
} | {
|
|
44
|
+
digest: string;
|
|
45
|
+
kind: "source-manifest";
|
|
46
|
+
path: string;
|
|
47
|
+
ref: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "ps-fixture";
|
|
50
|
+
path: string;
|
|
51
|
+
ref: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "retired-descriptor";
|
|
54
|
+
path: string;
|
|
55
|
+
ref: string;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../src/legacy-projection/provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,4BAA4B,GACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.js","sourceRoot":"","sources":["../../src/legacy-projection/provenance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-debris.d.ts","sourceRoot":"","sources":["../../src/legacy-projection/test-debris.ts"],"names":[],"mappings":"AAiDA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOtE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-debris scopes identified in protected-scopes-prod.tsv (production
|
|
3
|
+
* Data Gateway inventory, provided 2026-09-22): strings that are exact
|
|
4
|
+
* production grant/registration rows but are self-evidently test/dev
|
|
5
|
+
* artifacts, not real legacy app scopes.
|
|
6
|
+
*
|
|
7
|
+
* - `poc.spoof.<timestamp>` / `r2.pending-revoke.<timestamp>`: the source
|
|
8
|
+
* prefix itself (poc.spoof, r2.pending-revoke) is not a real connector id
|
|
9
|
+
* in either the desktop connector catalog or data-connectors' scope
|
|
10
|
+
* catalog, and the numeric suffix is a Unix-ms timestamp, not a stable
|
|
11
|
+
* scope name.
|
|
12
|
+
* - `seedbot.alpha` / `seedbot.beta`: "seedbot" has no connector anywhere in
|
|
13
|
+
* this repo or data-connectors; the name and the alpha/beta pairing read
|
|
14
|
+
* as a seed/fixture generator's own two test rows.
|
|
15
|
+
* - `demo.answer` / `write:demo.answer`: "demo" is not a connector id, and
|
|
16
|
+
* the `write:` prefix does not match this repo's `<source>.<scope>` scope
|
|
17
|
+
* grammar at all (verified: no other row in the 226-row TSV carries a
|
|
18
|
+
* colon).
|
|
19
|
+
*/
|
|
20
|
+
const POC_SPOOF_RE = /^poc\.spoof\.\d+$/;
|
|
21
|
+
const R2_PENDING_REVOKE_RE = /^r2\.pending-revoke\.\d+$/;
|
|
22
|
+
const SEEDBOT_RE = /^seedbot\.(alpha|beta)$/;
|
|
23
|
+
const TEST_DEBRIS_PATTERNS = [
|
|
24
|
+
{
|
|
25
|
+
test: (s) => POC_SPOOF_RE.test(s),
|
|
26
|
+
reason: "poc.spoof.<unix-ms> — proof-of-concept debris, timestamped suffix, no matching connector",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
test: (s) => R2_PENDING_REVOKE_RE.test(s),
|
|
30
|
+
reason: "r2.pending-revoke.<unix-ms> — revocation-flow test debris, no matching connector",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
test: (s) => SEEDBOT_RE.test(s),
|
|
34
|
+
reason: "seedbot.* — no seedbot connector exists; reads as seed-data generator's own test rows",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
test: (s) => s === "demo.answer" || s === "write:demo.answer",
|
|
38
|
+
reason: "demo.answer / write:demo.answer — 'demo' is not a connector id; write: prefix violates the source.scope grammar every other production row follows",
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
export function classifyAsTestDebris(scope) {
|
|
42
|
+
for (const { test, reason } of TEST_DEBRIS_PATTERNS) {
|
|
43
|
+
if (test(scope)) {
|
|
44
|
+
return reason;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=test-debris.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-debris.js","sourceRoot":"","sources":["../../src/legacy-projection/test-debris.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AACzD,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAE7C,MAAM,oBAAoB,GAGpB;IACJ;QACE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,MAAM,EACJ,0FAA0F;KAC7F;IACD;QACE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,MAAM,EACJ,kFAAkF;KACrF;IACD;QACE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/B,MAAM,EACJ,uFAAuF;KAC1F;IACD;QACE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,aAAa,IAAI,CAAC,KAAK,mBAAmB;QAC7D,MAAM,EACJ,oJAAoJ;KACvJ;CACF,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,oBAAoB,EAAE,CAAC;QACpD,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { LegacyScopeBindingProvenance } from "./provenance.js";
|
|
2
|
+
/** A PDPP selection: one source, one or more streams, no field filter (phase 1 always requests full records). */
|
|
3
|
+
export interface PdppSelection {
|
|
4
|
+
source: string;
|
|
5
|
+
streams: string[];
|
|
6
|
+
}
|
|
7
|
+
/** One raw PDPP record as returned by a Personal Server read, for one stream. */
|
|
8
|
+
export interface PdppRecord {
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
stream: string;
|
|
11
|
+
}
|
|
12
|
+
export type LegacyScopeLookupError = {
|
|
13
|
+
kind: "unknown_scope";
|
|
14
|
+
scope: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "unsupported_profile";
|
|
17
|
+
scope: string;
|
|
18
|
+
profileKey: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "test_debris_scope";
|
|
21
|
+
scope: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "gap";
|
|
25
|
+
scope: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
provenanceChecked: LegacyScopeBindingProvenance[];
|
|
28
|
+
};
|
|
29
|
+
export interface LegacyScopeLookupOk {
|
|
30
|
+
ok: true;
|
|
31
|
+
selection: PdppSelection;
|
|
32
|
+
}
|
|
33
|
+
export interface LegacyScopeLookupErr {
|
|
34
|
+
error: LegacyScopeLookupError;
|
|
35
|
+
ok: false;
|
|
36
|
+
}
|
|
37
|
+
export type LegacyScopeLookupResult = LegacyScopeLookupOk | LegacyScopeLookupErr;
|
|
38
|
+
export type ProjectionError = {
|
|
39
|
+
kind: "unknown_scope";
|
|
40
|
+
scope: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "unsupported_profile";
|
|
43
|
+
scope: string;
|
|
44
|
+
profileKey: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "missing_stream";
|
|
47
|
+
scope: string;
|
|
48
|
+
expectedStream: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "invalid_value";
|
|
51
|
+
scope: string;
|
|
52
|
+
reason: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "incomplete_scope";
|
|
55
|
+
scope: string;
|
|
56
|
+
reason: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "gap";
|
|
59
|
+
scope: string;
|
|
60
|
+
reason: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "empty_singleton";
|
|
63
|
+
scope: string;
|
|
64
|
+
};
|
|
65
|
+
export interface ProjectionOk {
|
|
66
|
+
diagnostics?: ProjectionDiagnostic[];
|
|
67
|
+
ok: true;
|
|
68
|
+
payload: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* `records_skipped` makes the whole projection `incomplete_scope`.
|
|
72
|
+
* `records_dropped` and `stream_missing` do not: the payload is served
|
|
73
|
+
* without the named rows, and the diagnostic says how many were left out.
|
|
74
|
+
*/
|
|
75
|
+
export type ProjectionDiagnostic = {
|
|
76
|
+
count: number;
|
|
77
|
+
kind: "records_skipped";
|
|
78
|
+
missingFields: string[];
|
|
79
|
+
scope: string;
|
|
80
|
+
} | {
|
|
81
|
+
count: number;
|
|
82
|
+
kind: "records_dropped";
|
|
83
|
+
reasons: string[];
|
|
84
|
+
scope: string;
|
|
85
|
+
stream: string;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "stream_missing";
|
|
88
|
+
scope: string;
|
|
89
|
+
stream: string;
|
|
90
|
+
};
|
|
91
|
+
export interface ProjectionErr {
|
|
92
|
+
error: ProjectionError;
|
|
93
|
+
ok: false;
|
|
94
|
+
}
|
|
95
|
+
export type ProjectionResult = ProjectionOk | ProjectionErr;
|
|
96
|
+
/**
|
|
97
|
+
* Which streams a caller actually fetched for this request, distinct from
|
|
98
|
+
* which of those streams produced records. A stream absent from this list
|
|
99
|
+
* was never fetched (`missing_stream`); a stream present in this list with
|
|
100
|
+
* zero matching records in `records` legitimately had zero rows. This is
|
|
101
|
+
* how "fetched, zero rows" is expressed without a fake marker record.
|
|
102
|
+
*/
|
|
103
|
+
export interface ProjectPdppRecordsOptions {
|
|
104
|
+
fetchedStreams: string[];
|
|
105
|
+
/** Selected signed connector key. Omitted for the original PAT binding. */
|
|
106
|
+
profileKey?: string;
|
|
107
|
+
/**
|
|
108
|
+
* ISO timestamp for generated fields (`fetched_at`, `fetchedAt`, a null
|
|
109
|
+
* memory `created_at`). Pass it to make the same records project to the
|
|
110
|
+
* same bytes. Defaults to the wall clock.
|
|
111
|
+
*/
|
|
112
|
+
now?: string;
|
|
113
|
+
/**
|
|
114
|
+
* A stream absent from `fetchedStreams` normally fails with
|
|
115
|
+
* `missing_stream`. When this is true, a binding that can still produce a
|
|
116
|
+
* useful payload without a join stream does so and reports
|
|
117
|
+
* `stream_missing` instead. Today only `chatgpt.conversations` can (it
|
|
118
|
+
* projects conversations with `messages: []`). For read-time callers whose
|
|
119
|
+
* join stream has no stored version yet.
|
|
120
|
+
*/
|
|
121
|
+
allowMissingJoinStreams?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Feed rows to the binding sorted by (stream, primary key) instead of in
|
|
124
|
+
* input order, so the output does not depend on the order rows were
|
|
125
|
+
* stored in. Top-level arrays then follow key order, not source order,
|
|
126
|
+
* except `chatgpt.conversations`, which follows legacy's order: newest
|
|
127
|
+
* `update_time` first, then id.
|
|
128
|
+
*/
|
|
129
|
+
orderByPrimaryKey?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* One legacy scope's binding. `project` and `requiredStreams` are absent for
|
|
133
|
+
* a scope this phase declares a gap for (see LEGACY_SCOPE_GAPS) — a gap has
|
|
134
|
+
* no binding entry at all, by design: "no entry, no fabricated mapping."
|
|
135
|
+
*/
|
|
136
|
+
export interface LegacyScopeBinding {
|
|
137
|
+
/**
|
|
138
|
+
* Per bound stream, the exact set of declared field names `project()`
|
|
139
|
+
* reads off that stream's records. Checked by the self-check against the
|
|
140
|
+
* vendored declaration's own `schema.properties` keys — deleting or
|
|
141
|
+
* renaming a field here in the declaration must make this list disagree
|
|
142
|
+
* and fail the self-check (S1).
|
|
143
|
+
*/
|
|
144
|
+
fieldsRead: Record<string, string[]>;
|
|
145
|
+
/** Legacy JSON Schema path this binding's output must validate against, relative to ./legacy-schemas. */
|
|
146
|
+
legacySchemaPath: string;
|
|
147
|
+
/**
|
|
148
|
+
* Every legacy field this binding drops, derives, reformats, or defaults,
|
|
149
|
+
* relative to the legacy connector source at the pin — not "not yet
|
|
150
|
+
* implemented", the permanent, documented shape of this projection.
|
|
151
|
+
*/
|
|
152
|
+
lossy: string[];
|
|
153
|
+
/** The PDPP source id (`connector_id`), e.g. "https://registry.pdpp.dev/connectors/meta" — never the short connector key. */
|
|
154
|
+
pdppSource: string;
|
|
155
|
+
pdppStreams: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Per bound stream, the exact primary-key field list `project()` relies on
|
|
158
|
+
* for joins/dedup (e.g. amazon's order_items→orders join key). Checked by
|
|
159
|
+
* the self-check for exact equality with the vendored declaration's own
|
|
160
|
+
* `primary_key` — a binding that names a declared-but-wrong key must fail.
|
|
161
|
+
*/
|
|
162
|
+
primaryKey: Record<string, string[]>;
|
|
163
|
+
project: (records: PdppRecord[], options: ProjectPdppRecordsOptions) => ProjectionResult;
|
|
164
|
+
provenance: LegacyScopeBindingProvenance[];
|
|
165
|
+
scope: string;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy-projection/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,iHAAiH;AACjH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5D;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,4BAA4B,EAAE,CAAC;CACnD,CAAC;AAEN,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,IAAI,CAAC;IACT,SAAS,EAAE,aAAa,CAAC;CAC1B;AACD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,sBAAsB,CAAC;IAC9B,EAAE,EAAE,KAAK,CAAC;CACX;AACD,MAAM,MAAM,uBAAuB,GACjC,mBAA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,GACD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,eAAe,CAAC;IACvB,EAAE,EAAE,KAAK,CAAC;CACX;AACD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,aAAa,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,yGAAyG;IACzG,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6HAA6H;IAC7H,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,OAAO,EAAE,CACP,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,yBAAyB,KAC/B,gBAAgB,CAAC;IACtB,UAAU,EAAE,4BAA4B,EAAE,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/legacy-projection/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendatalabs/personal-server-ts-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Protocol logic for the Vana Personal Server — auth, grants, scopes, storage, keys",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -147,5 +147,8 @@
|
|
|
147
147
|
"unpdf": "^1.6.2",
|
|
148
148
|
"viem": "^2.54.2",
|
|
149
149
|
"zod": "^4.4.3"
|
|
150
|
+
},
|
|
151
|
+
"devDependencies": {
|
|
152
|
+
"ajv": "^8.20.0"
|
|
150
153
|
}
|
|
151
154
|
}
|