@eide/foir-cli 0.11.1 → 0.11.3

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.js +38 -4
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -1519,6 +1519,9 @@ function createRecordsMethods(client) {
1519
1519
  offset: params.offset ?? 0,
1520
1520
  customerId: params.customerId,
1521
1521
  search: params.search,
1522
+ // CLI is admin-equivalent and must see drafts; without preview the
1523
+ // platform now hides unpublished records on publishable models.
1524
+ preview: true,
1522
1525
  filters: params.filters?.map(
1523
1526
  (f) => create4(RecordFilterSchema, {
1524
1527
  field: f.field,
@@ -3475,9 +3478,12 @@ function registerSelectProjectCommand(program2, globalOpts) {
3475
3478
  selectedProject = projects.find((p) => p.id === projectId);
3476
3479
  }
3477
3480
  console.log("\nProvisioning API key for CLI access...");
3478
- await client.identity.switchTenant(selectedProject.tenantId);
3479
- await client.identity.switchProject(selectedProject.id);
3480
- const { apiKey, apiKeyId } = await provisionApiKey(client);
3481
+ const scopedClient = createPlatformClientWithHeaders(apiUrl, {
3482
+ Authorization: `Bearer ${credentials.accessToken}`,
3483
+ "x-tenant-id": selectedProject.tenantId,
3484
+ "x-project-id": selectedProject.id
3485
+ });
3486
+ const { apiKey, apiKeyId } = await provisionApiKey(scopedClient);
3481
3487
  await writeProjectContext(
3482
3488
  {
3483
3489
  id: selectedProject.id,
@@ -5690,8 +5696,24 @@ function registerPushCommand(program2, globalOpts) {
5690
5696
  );
5691
5697
  }
5692
5698
  const gOpts = globalOpts();
5693
- const client = await createPlatformClient(gOpts);
5694
5699
  const resolved = await resolveProjectContext(gOpts);
5700
+ const pin = config2.project;
5701
+ if (pin) {
5702
+ if (!resolved) {
5703
+ throw new Error(
5704
+ `foir.config.ts is pinned to project "${pin.name ?? pin.id}" (${pin.id}), but no project context is selected. Run \`foir select-project\` first.`
5705
+ );
5706
+ }
5707
+ if (resolved.project.id !== pin.id || resolved.project.tenantId !== pin.tenantId) {
5708
+ throw new Error(
5709
+ `Project mismatch \u2014 refusing to push.
5710
+ foir.config.ts pin: ${pin.name ?? pin.id} (${pin.id})
5711
+ resolved (${resolved.source}): ${resolved.project.name} (${resolved.project.id})
5712
+ Hand-edit foir.config.ts or run \`foir select-project\` to align them.`
5713
+ );
5714
+ }
5715
+ }
5716
+ const client = await createPlatformClient(gOpts);
5695
5717
  console.log(
5696
5718
  chalk6.dim(`Pushing config "${config2.key}" to platform...`)
5697
5719
  );
@@ -5744,6 +5766,18 @@ function registerPushCommand(program2, globalOpts) {
5744
5766
  console.log(` Config Key: ${chalk6.cyan(config2.key)}`);
5745
5767
  console.log();
5746
5768
  printSummary(summary);
5769
+ if (!pin && resolved) {
5770
+ console.log();
5771
+ console.log(chalk6.dim("Tip: pin this folder to its project by adding the following to foir.config.ts:"));
5772
+ console.log(chalk6.dim(" project: {"));
5773
+ console.log(chalk6.dim(` id: '${resolved.project.id}',`));
5774
+ console.log(chalk6.dim(` tenantId: '${resolved.project.tenantId}',`));
5775
+ if (resolved.project.name) {
5776
+ console.log(chalk6.dim(` name: '${resolved.project.name}',`));
5777
+ }
5778
+ console.log(chalk6.dim(" },"));
5779
+ console.log(chalk6.dim("Future pushes will refuse to run if the resolved project drifts from this id."));
5780
+ }
5747
5781
  const envPath = resolve4(opts.env ?? ".env");
5748
5782
  const envWrites = [];
5749
5783
  for (const pk of summary.apiKeys) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -50,7 +50,7 @@
50
50
  "@bufbuild/protovalidate": "^1.1.1",
51
51
  "@connectrpc/connect": "^2.0.0",
52
52
  "@connectrpc/connect-node": "^2.0.0",
53
- "@eide/foir-proto-ts": "^0.26.0",
53
+ "@eide/foir-proto-ts": "^0.29.1",
54
54
  "chalk": "^5.3.0",
55
55
  "commander": "^12.1.0",
56
56
  "dotenv": "^16.4.5",