gipity 1.1.41 → 1.1.42

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.
@@ -68,6 +68,8 @@ export function scopesFromFlags(opts) {
68
68
  }
69
69
  if (opts.files !== undefined)
70
70
  scopes.files = opts.files;
71
+ if (opts.approvals !== undefined)
72
+ scopes.approvals = opts.approvals;
71
73
  if (opts.ip !== undefined) {
72
74
  const ips = splitList(opts.ip);
73
75
  if (!ips.length)
@@ -87,6 +89,8 @@ export function describeScopes(scopes) {
87
89
  parts.push(`tables: ${Object.entries(scopes.tables).map(([t, a]) => `${t}:${a}`).join(',')}`);
88
90
  if (scopes.files)
89
91
  parts.push(`files: ${scopes.files}`);
92
+ if (scopes.approvals)
93
+ parts.push(`approvals: ${scopes.approvals}`);
90
94
  if (scopes.ip)
91
95
  parts.push(`ip: ${scopes.ip.join(',')}`);
92
96
  return parts.join(' ');
@@ -104,6 +108,7 @@ keyCommand
104
108
  .option('--functions <names>', 'Scope: only these functions (comma-separated)')
105
109
  .option('--tables <list>', 'Scope: only these Records tables, e.g. commands:write,logs:read')
106
110
  .addOption(new Option('--files <access>', 'Scope: app files access').choices(['read', 'write']))
111
+ .addOption(new Option('--approvals <access>', 'Scope: read and consume passkey approvals').choices(['read']))
107
112
  .option('--ip <list>', 'Scope: only from these IPs / CIDR ranges (comma-separated)')
108
113
  .option(...projectOpt)
109
114
  .option('--json', 'Output as JSON')
@@ -7,6 +7,11 @@
7
7
  * `--inspect` to peek inside a source - metadata, contents, deploy phases,
8
8
  * and each function's permission surface - without creating anything.
9
9
  *
10
+ * A bundle saved with `gipity save --with-data` also carries database rows:
11
+ * the server builds the new app's database from the bundle's migrations and
12
+ * loads them, and the summary lists each table's row count (`--inspect` shows
13
+ * the same counts without loading anything).
14
+ *
10
15
  * Sources:
11
16
  * - a local .gip file (from `gipity save`) - uploaded as raw zip bytes
12
17
  * - `github:owner/repo[/sub/path][@ref]` or a github.com URL - resolved
@@ -88,6 +93,13 @@ function printManifest(m) {
88
93
  }
89
94
  }
90
95
  }
96
+ /** One line per table: ` database.table N rows`. */
97
+ function printTableCounts(databases) {
98
+ const rows = databases.flatMap(db => db.tables.map(t => ({ name: `${db.database}.${t.table}`, rows: t.rows })));
99
+ const width = Math.max(0, ...rows.map(r => r.name.length));
100
+ for (const r of rows)
101
+ console.log(` ${r.name.padEnd(width)} ${muted(`${r.rows} row(s)`)}`);
102
+ }
91
103
  function printInspect(d, source) {
92
104
  if (d.meta) {
93
105
  console.log(bold(d.meta.name));
@@ -104,13 +116,22 @@ function printInspect(d, source) {
104
116
  console.log('');
105
117
  printManifest(d.manifest);
106
118
  console.log('');
119
+ if (d.data) {
120
+ const tables = d.data.databases.reduce((n, db) => n + db.tables.length, 0);
121
+ console.log(bold(`Data: ${d.data.rows} row(s) in ${tables} table(s), ${formatBytes(d.data.bytes)}`));
122
+ printTableCounts(d.data.databases);
123
+ }
124
+ else {
125
+ console.log(muted('Data: none (code, migrations and seeds only)'));
126
+ }
127
+ console.log('');
107
128
  console.log(muted('Load it with `gipity load ' + source + '` - always creates a NEW project.'));
108
129
  }
109
130
  export const loadCommand = new Command('load')
110
131
  .description('Create a new app from a .gip bundle or a GitHub repo')
111
132
  .argument('<source>', 'A .gip file (from `gipity save`), github:owner/repo[/sub/path][@ref], or a github.com URL')
112
133
  .option('--name <name>', 'Name for the new project (default: the source\'s saved name)')
113
- .option('--inspect', 'Peek inside the source - contents, deploy phases, function permissions - without creating anything')
134
+ .option('--inspect', 'Peek inside the source - contents, deploy phases, function permissions, saved data - without creating anything')
114
135
  .option('--json', 'Output as JSON')
115
136
  .addHelpText('after', '\nLoad always creates a NEW project - it never merges into an existing one.'
116
137
  + '\nGitHub sources need a one-time `gipity github connect` (re-run it to grant more repos).')
@@ -190,7 +211,10 @@ export const loadCommand = new Command('load')
190
211
  failed: data.failed,
191
212
  partial,
192
213
  applied,
214
+ ...(data.data ? { data: data.data } : {}),
193
215
  }));
216
+ if (data.data && !data.data.loaded)
217
+ process.exitCode = 1;
194
218
  return;
195
219
  }
196
220
  console.log(success(`Created "${project.name}" (${project.slug}) from ${sourceLabel}`));
@@ -205,7 +229,25 @@ export const loadCommand = new Command('load')
205
229
  console.warn(warning(` ! ${f.path}: ${f.error}`));
206
230
  console.warn(warning('The project was still created and linked; the files above are missing from it.'));
207
231
  }
232
+ if (data.data?.loaded) {
233
+ console.log('');
234
+ console.log(success(`Loaded ${data.data.rows} row(s) into the app's database:`));
235
+ printTableCounts(data.data.databases);
236
+ }
237
+ else if (data.data) {
238
+ console.log('');
239
+ console.warn(warning(`The bundle's rows were not loaded: ${data.data.error}`));
240
+ console.warn(warning('The project was still created and linked, with an empty database. Delete it with `gipity project delete` and load again once the problem is fixed.'));
241
+ process.exitCode = 1;
242
+ }
208
243
  console.log('');
209
- console.log(`${muted('Next:')} cd ${dir} && ${brand('gipity deploy dev')}`);
244
+ if (data.data?.loaded) {
245
+ // The rows went into prod (where a new app lives); a dev environment starts empty.
246
+ console.log(`${muted('Next:')} cd ${dir} && ${brand('gipity deploy prod')}`);
247
+ console.log(muted('The rows are in the prod database. `gipity env create dev --data` gives you a dev copy with them.'));
248
+ }
249
+ else {
250
+ console.log(`${muted('Next:')} cd ${dir} && ${brand('gipity deploy dev')}`);
251
+ }
210
252
  }));
211
253
  //# sourceMappingURL=load.js.map
@@ -3,8 +3,10 @@
3
3
  *
4
4
  * A .gip is a zip of the project's file tree plus a reserved
5
5
  * `_gip/manifest.json` metadata entry. It pairs with `gipity load`, which
6
- * creates a brand-new project from a bundle. Code-only: secrets, custom
7
- * domains, chats, and database rows are never in a .gip.
6
+ * creates a brand-new project from a bundle. Secrets, custom domains, chats
7
+ * and app runtime uploads are never in a .gip. Database rows are left out
8
+ * unless the owner passes `--with-data` (every table's rows, up to the
9
+ * server's size cap); the schema always comes from the bundle's migrations.
8
10
  */
9
11
  import fs from 'fs';
10
12
  import path from 'path';
@@ -45,11 +47,14 @@ function dispositionFilename(headers) {
45
47
  export const saveCommand = new Command('save')
46
48
  .description('Save this app as a portable .gip bundle')
47
49
  .argument('[output]', 'Output .gip path, or a directory to write <slug>.gip into (default: ./<slug>.gip)')
50
+ .option('--with-data', 'Also save every table\'s rows from the app\'s database (owner only)')
48
51
  .option('--json', 'Output as JSON')
49
- .addHelpText('after', '\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.')
52
+ .addHelpText('after', '\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.'
53
+ + '\nWith --with-data, load also builds the database from the migrations and loads the rows.')
50
54
  .action((output, opts) => run('Save', async () => {
51
55
  const config = requireConfig();
52
- const doExport = () => downloadWithHeaders(`/projects/${config.projectGuid}/export`);
56
+ const query = opts.withData ? '?with_data=1' : '';
57
+ const doExport = () => downloadWithHeaders(`/projects/${config.projectGuid}/export${query}`);
53
58
  const { buffer, headers } = opts.json
54
59
  ? await doExport()
55
60
  : await withSpinner('Exporting...', doExport, { done: null });
@@ -63,6 +68,9 @@ export const saveCommand = new Command('save')
63
68
  const sha256 = createHash('sha256').update(buffer).digest('hex');
64
69
  const skipped = Number(headers.get('x-gip-skipped') ?? 0);
65
70
  const entries = zipEntryCount(buffer);
71
+ const data = opts.withData
72
+ ? { tables: Number(headers.get('x-gip-data-tables') ?? 0), rows: Number(headers.get('x-gip-data-rows') ?? 0) }
73
+ : null;
66
74
  if (opts.json) {
67
75
  console.log(JSON.stringify({
68
76
  path: dest,
@@ -70,6 +78,7 @@ export const saveCommand = new Command('save')
70
78
  sha256,
71
79
  ...(entries !== null ? { entries } : {}),
72
80
  skipped,
81
+ ...(data ? { data } : {}),
73
82
  }));
74
83
  return;
75
84
  }
@@ -78,12 +87,18 @@ export const saveCommand = new Command('save')
78
87
  console.log(` Size: ${formatBytes(buffer.length)}`);
79
88
  if (entries !== null)
80
89
  console.log(` Entries: ${entries} (including the bundle manifest)`);
90
+ if (data)
91
+ console.log(` Data: ${data.rows} row(s) from ${data.tables} table(s)`);
81
92
  console.log(` SHA-256: ${sha256}`);
82
93
  if (skipped > 0) {
83
94
  console.log('');
84
95
  console.warn(warning(`${skipped} file(s) were skipped (unreadable or over 100 MB) - this bundle is partial.`));
85
96
  console.warn(warning('Large assets belong in Gipity Storage, not in a code bundle.'));
86
97
  }
98
+ if (data) {
99
+ console.log('');
100
+ console.warn(warning('This bundle holds the app\'s data. Share it only with people allowed to see that data.'));
101
+ }
87
102
  console.log('');
88
103
  console.log(muted('Restore anywhere with `gipity load ' + path.basename(dest) + '` (creates a new project).'));
89
104
  }));
package/dist/index.js CHANGED
@@ -36524,6 +36524,7 @@ function scopesFromFlags(opts) {
36524
36524
  }
36525
36525
  }
36526
36526
  if (opts.files !== void 0) scopes.files = opts.files;
36527
+ if (opts.approvals !== void 0) scopes.approvals = opts.approvals;
36527
36528
  if (opts.ip !== void 0) {
36528
36529
  const ips = splitList(opts.ip);
36529
36530
  if (!ips.length) throw new Error("--ip needs at least one address or CIDR range");
@@ -36537,6 +36538,7 @@ function describeScopes(scopes) {
36537
36538
  if (scopes.functions) parts.push(`fn: ${scopes.functions.join(",")}`);
36538
36539
  if (scopes.tables) parts.push(`tables: ${Object.entries(scopes.tables).map(([t, a]) => `${t}:${a}`).join(",")}`);
36539
36540
  if (scopes.files) parts.push(`files: ${scopes.files}`);
36541
+ if (scopes.approvals) parts.push(`approvals: ${scopes.approvals}`);
36540
36542
  if (scopes.ip) parts.push(`ip: ${scopes.ip.join(",")}`);
36541
36543
  return parts.join(" ");
36542
36544
  }
@@ -36545,7 +36547,7 @@ async function projectGuid(opts) {
36545
36547
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
36546
36548
  return config.projectGuid;
36547
36549
  }
36548
- keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option("--functions <names>", "Scope: only these functions (comma-separated)").option("--tables <list>", "Scope: only these Records tables, e.g. commands:write,logs:read").addOption(new Option("--files <access>", "Scope: app files access").choices(["read", "write"])).option("--ip <list>", "Scope: only from these IPs / CIDR ranges (comma-separated)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
36550
+ keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option("--functions <names>", "Scope: only these functions (comma-separated)").option("--tables <list>", "Scope: only these Records tables, e.g. commands:write,logs:read").addOption(new Option("--files <access>", "Scope: app files access").choices(["read", "write"])).addOption(new Option("--approvals <access>", "Scope: read and consume passkey approvals").choices(["read"])).option("--ip <list>", "Scope: only from these IPs / CIDR ranges (comma-separated)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
36549
36551
  const body = { name, role: opts.role };
36550
36552
  const scopes = scopesFromFlags(opts);
36551
36553
  if (scopes) body.scopes = scopes;
@@ -43251,9 +43253,10 @@ function dispositionFilename(headers) {
43251
43253
  const m = /filename="([^"]+)"/.exec(headers.get("content-disposition") ?? "");
43252
43254
  return m ? m[1] : null;
43253
43255
  }
43254
- var saveCommand = new Command("save").description("Save this app as a portable .gip bundle").argument("[output]", "Output .gip path, or a directory to write <slug>.gip into (default: ./<slug>.gip)").option("--json", "Output as JSON").addHelpText("after", "\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.").action((output, opts) => run("Save", async () => {
43256
+ var saveCommand = new Command("save").description("Save this app as a portable .gip bundle").argument("[output]", "Output .gip path, or a directory to write <slug>.gip into (default: ./<slug>.gip)").option("--with-data", "Also save every table's rows from the app's database (owner only)").option("--json", "Output as JSON").addHelpText("after", "\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.\nWith --with-data, load also builds the database from the migrations and loads the rows.").action((output, opts) => run("Save", async () => {
43255
43257
  const config = requireConfig2();
43256
- const doExport = () => downloadWithHeaders(`/projects/${config.projectGuid}/export`);
43258
+ const query = opts.withData ? "?with_data=1" : "";
43259
+ const doExport = () => downloadWithHeaders(`/projects/${config.projectGuid}/export${query}`);
43257
43260
  const { buffer, headers } = opts.json ? await doExport() : await withSpinner("Exporting...", doExport, { done: null });
43258
43261
  const filename = dispositionFilename(headers) ?? `${config.projectSlug}.gip`;
43259
43262
  let dest = path2.resolve(output ?? filename);
@@ -43265,13 +43268,15 @@ var saveCommand = new Command("save").description("Save this app as a portable .
43265
43268
  const sha2562 = createHash4("sha256").update(buffer).digest("hex");
43266
43269
  const skipped = Number(headers.get("x-gip-skipped") ?? 0);
43267
43270
  const entries = zipEntryCount(buffer);
43271
+ const data = opts.withData ? { tables: Number(headers.get("x-gip-data-tables") ?? 0), rows: Number(headers.get("x-gip-data-rows") ?? 0) } : null;
43268
43272
  if (opts.json) {
43269
43273
  console.log(JSON.stringify({
43270
43274
  path: dest,
43271
43275
  bytes: buffer.length,
43272
43276
  sha256: sha2562,
43273
43277
  ...entries !== null ? { entries } : {},
43274
- skipped
43278
+ skipped,
43279
+ ...data ? { data } : {}
43275
43280
  }));
43276
43281
  return;
43277
43282
  }
@@ -43279,12 +43284,17 @@ var saveCommand = new Command("save").description("Save this app as a portable .
43279
43284
  console.log(` Path: ${dest}`);
43280
43285
  console.log(` Size: ${formatBytes(buffer.length)}`);
43281
43286
  if (entries !== null) console.log(` Entries: ${entries} (including the bundle manifest)`);
43287
+ if (data) console.log(` Data: ${data.rows} row(s) from ${data.tables} table(s)`);
43282
43288
  console.log(` SHA-256: ${sha2562}`);
43283
43289
  if (skipped > 0) {
43284
43290
  console.log("");
43285
43291
  console.warn(warning(`${skipped} file(s) were skipped (unreadable or over 100 MB) - this bundle is partial.`));
43286
43292
  console.warn(warning("Large assets belong in Gipity Storage, not in a code bundle."));
43287
43293
  }
43294
+ if (data) {
43295
+ console.log("");
43296
+ console.warn(warning("This bundle holds the app's data. Share it only with people allowed to see that data."));
43297
+ }
43288
43298
  console.log("");
43289
43299
  console.log(muted("Restore anywhere with `gipity load " + path2.basename(dest) + "` (creates a new project)."));
43290
43300
  }));
@@ -43348,6 +43358,11 @@ function printManifest(m) {
43348
43358
  }
43349
43359
  }
43350
43360
  }
43361
+ function printTableCounts(databases) {
43362
+ const rows = databases.flatMap((db2) => db2.tables.map((t) => ({ name: `${db2.database}.${t.table}`, rows: t.rows })));
43363
+ const width = Math.max(0, ...rows.map((r) => r.name.length));
43364
+ for (const r of rows) console.log(` ${r.name.padEnd(width)} ${muted(`${r.rows} row(s)`)}`);
43365
+ }
43351
43366
  function printInspect(d, source) {
43352
43367
  if (d.meta) {
43353
43368
  console.log(bold(d.meta.name));
@@ -43362,9 +43377,17 @@ function printInspect(d, source) {
43362
43377
  console.log("");
43363
43378
  printManifest(d.manifest);
43364
43379
  console.log("");
43380
+ if (d.data) {
43381
+ const tables = d.data.databases.reduce((n, db2) => n + db2.tables.length, 0);
43382
+ console.log(bold(`Data: ${d.data.rows} row(s) in ${tables} table(s), ${formatBytes(d.data.bytes)}`));
43383
+ printTableCounts(d.data.databases);
43384
+ } else {
43385
+ console.log(muted("Data: none (code, migrations and seeds only)"));
43386
+ }
43387
+ console.log("");
43365
43388
  console.log(muted("Load it with `gipity load " + source + "` - always creates a NEW project."));
43366
43389
  }
43367
- var loadCommand = new Command("load").description("Create a new app from a .gip bundle or a GitHub repo").argument("<source>", "A .gip file (from `gipity save`), github:owner/repo[/sub/path][@ref], or a github.com URL").option("--name <name>", "Name for the new project (default: the source's saved name)").option("--inspect", "Peek inside the source - contents, deploy phases, function permissions - without creating anything").option("--json", "Output as JSON").addHelpText("after", "\nLoad always creates a NEW project - it never merges into an existing one.\nGitHub sources need a one-time `gipity github connect` (re-run it to grant more repos).").action((source, opts) => run("Load", async () => {
43390
+ var loadCommand = new Command("load").description("Create a new app from a .gip bundle or a GitHub repo").argument("<source>", "A .gip file (from `gipity save`), github:owner/repo[/sub/path][@ref], or a github.com URL").option("--name <name>", "Name for the new project (default: the source's saved name)").option("--inspect", "Peek inside the source - contents, deploy phases, function permissions, saved data - without creating anything").option("--json", "Output as JSON").addHelpText("after", "\nLoad always creates a NEW project - it never merges into an existing one.\nGitHub sources need a one-time `gipity github connect` (re-run it to grant more repos).").action((source, opts) => run("Load", async () => {
43368
43391
  const github = isGithubSource(source);
43369
43392
  if (!github && /^https?:\/\//i.test(source)) {
43370
43393
  throw new Error("Only GitHub URLs are supported for now - pass github:owner/repo, a github.com URL, or a local .gip file.");
@@ -43428,8 +43451,10 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
43428
43451
  written: data.written,
43429
43452
  failed: data.failed,
43430
43453
  partial,
43431
- applied
43454
+ applied,
43455
+ ...data.data ? { data: data.data } : {}
43432
43456
  }));
43457
+ if (data.data && !data.data.loaded) process.exitCode = 1;
43433
43458
  return;
43434
43459
  }
43435
43460
  console.log(success(`Created "${project.name}" (${project.slug}) from ${sourceLabel}`));
@@ -43442,8 +43467,23 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
43442
43467
  for (const f of data.failed ?? []) console.warn(warning(` ! ${f.path}: ${f.error}`));
43443
43468
  console.warn(warning("The project was still created and linked; the files above are missing from it."));
43444
43469
  }
43470
+ if (data.data?.loaded) {
43471
+ console.log("");
43472
+ console.log(success(`Loaded ${data.data.rows} row(s) into the app's database:`));
43473
+ printTableCounts(data.data.databases);
43474
+ } else if (data.data) {
43475
+ console.log("");
43476
+ console.warn(warning(`The bundle's rows were not loaded: ${data.data.error}`));
43477
+ console.warn(warning("The project was still created and linked, with an empty database. Delete it with `gipity project delete` and load again once the problem is fixed."));
43478
+ process.exitCode = 1;
43479
+ }
43445
43480
  console.log("");
43446
- console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy dev")}`);
43481
+ if (data.data?.loaded) {
43482
+ console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy prod")}`);
43483
+ console.log(muted("The rows are in the prod database. `gipity env create dev --data` gives you a dev copy with them."));
43484
+ } else {
43485
+ console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy dev")}`);
43486
+ }
43447
43487
  }));
43448
43488
 
43449
43489
  // src/commands/logs.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.41",
3
+ "version": "1.1.42",
4
4
  "description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
5
5
  "bin": {
6
6
  "gipity": "dist/updater/shim.js",