sparta_worlds 0.7.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/cli/import.js +26 -1
  2. package/package.json +1 -1
@@ -145,6 +145,18 @@ async function listAll(opts, path, max, params = {}) {
145
145
  }
146
146
  const num = (v, fallback = 0) => (typeof v === "number" ? v : fallback);
147
147
  const str = (v) => (typeof v === "string" ? v : undefined);
148
+ const emailKey = (c) => {
149
+ const e = str(c.email)?.trim().toLowerCase();
150
+ return e ? e : undefined;
151
+ };
152
+ const byCreatedThenId = (a, b) => {
153
+ const d = num(a.created) - num(b.created);
154
+ if (d !== 0)
155
+ return d;
156
+ const x = String(a.id);
157
+ const y = String(b.id);
158
+ return x < y ? -1 : x > y ? 1 : 0;
159
+ };
148
160
  export async function importStripeSeed(opts) {
149
161
  const skipped = [];
150
162
  const products = await listAll(opts, "/v1/products", opts.limit);
@@ -271,6 +283,19 @@ export async function importStripeSeed(opts) {
271
283
  group.push(ch);
272
284
  chargesByInvoice.set(invoiceId, group);
273
285
  }
286
+ customers.sort(byCreatedThenId);
287
+ invoices.sort(byCreatedThenId);
288
+ subscriptions.sort(byCreatedThenId);
289
+ const emailOwner = new Map();
290
+ for (const c of customers) {
291
+ const key = emailKey(c);
292
+ if (key !== undefined && !emailOwner.has(key))
293
+ emailOwner.set(key, String(c.id));
294
+ }
295
+ const pseudonymEmail = (c) => {
296
+ const key = emailKey(c);
297
+ return fakeIdentity(key === undefined ? String(c.id) : (emailOwner.get(key) ?? String(c.id))).email;
298
+ };
274
299
  const keepMetadata = opts.keepMetadata === true;
275
300
  const manifest = {
276
301
  scrub: {
@@ -317,7 +342,7 @@ export async function importStripeSeed(opts) {
317
342
  const identities = [];
318
343
  const seedCustomers = customers.map((c) => {
319
344
  const id = String(c.id);
320
- const fake = fakeIdentity(id);
345
+ const fake = { name: fakeIdentity(id).name, email: pseudonymEmail(c) };
321
346
  identities.push({
322
347
  id,
323
348
  email: str(c.email) ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparta_worlds",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "worlds — a flight simulator for AI agents that act on business systems: stateful, deterministic twins of the connectors they use, Stripe first",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",