zinkee 0.1.34 → 0.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zinkee",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "CLI for Zinkee API v2",
5
5
  "type": "module",
6
6
  "bin": {
@@ -750,7 +750,12 @@ export function registerRecordsCommands(
750
750
  .command("create")
751
751
  .description("Create one or more records")
752
752
  .argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector)
753
- .option("--set <field=value>", "set a string field", collectKeyValueAssignments, [])
753
+ .option(
754
+ "--set <field=value>",
755
+ "set a string field (reference fields: a record id, 'recordId::label', or an exact display value)",
756
+ collectKeyValueAssignments,
757
+ [],
758
+ )
754
759
  .option("--set-json <field=json>", "set a structured field", collectJsonAssignments, [])
755
760
  .option("--raw <json>", "raw JSON object payload")
756
761
  .option("--raw-file <path>", "path to a raw JSON object payload")
@@ -790,7 +795,12 @@ export function registerRecordsCommands(
790
795
  .description("Update a record")
791
796
  .argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector)
792
797
  .argument("<record>", "record uuid or slug", parseUuidOrSlugSelector)
793
- .option("--set <field=value>", "set a string field", collectKeyValueAssignments, [])
798
+ .option(
799
+ "--set <field=value>",
800
+ "set a string field (reference fields: a record id, 'recordId::label', or an exact display value)",
801
+ collectKeyValueAssignments,
802
+ [],
803
+ )
794
804
  .option("--set-json <field=json>", "set a structured field", collectJsonAssignments, [])
795
805
  .option("--unset <field>", "unset a field", collectStringValues, [])
796
806
  .option("--raw <json>", "raw JSON object of fields to set")
@@ -177,13 +177,15 @@ describe("getCommandExamples", () => {
177
177
  }
178
178
  });
179
179
 
180
- it("offers both a minimal and a multi-type records create example", () => {
180
+ it("offers minimal, multi-type, and reference records create examples", () => {
181
181
  const examples = getCommandExamples("records create");
182
182
 
183
- expect(examples).toHaveLength(2);
183
+ expect(examples).toHaveLength(3);
184
184
  expect(examples[0]?.raw).toContain('"contact-name"');
185
185
  expect(examples[1]?.raw).toContain('"customer-ref"');
186
186
  expect(examples[1]?.raw).toContain('"owner"');
187
+ expect(examples[2]?.raw).toContain('"customer-ref"');
188
+ expect(examples[2]?.response).toContain("data_field_reference_not_found");
187
189
  });
188
190
 
189
191
  it("provides full/minimal/folder variants for schemas create", () => {
@@ -698,7 +698,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
698
698
  },
699
699
  {
700
700
  description:
701
- "Create many records from a JSON array file (one object per record, slug -> value). Best-effort: valid records are created and invalid ones are reported per index in 'errors'. ReferenceField values must match the target's current targetDisplayField.",
701
+ "Create many records from a JSON array file (one object per record, slug -> value). Best-effort: valid records are created and invalid ones are reported per index in 'errors'. ReferenceField values accept the target record id (a bare UUID, or the compound 'recordId::anything' whose label is ignored) or an exact display value; the server stores the canonical 'recordId::displayValue'.",
702
702
  command: `zinkee --json records create contacts --records-file ./records.json`,
703
703
  raw: `{
704
704
  "records": [
@@ -729,6 +729,31 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
729
729
  "action": "Use a valid field slug from the schema and retry."
730
730
  }
731
731
  ]
732
+ }`,
733
+ },
734
+ {
735
+ description:
736
+ "Set a ReferenceField by the target record id (a bare UUID, or the compound 'recordId::anything' whose label is ignored) or by an exact display value. The server resolves and stores the canonical 'recordId::displayValue'. Unknown references are rejected per index with reason 'data_field_reference_not_found'.",
737
+ command:
738
+ `zinkee --json records create deals --set deal-name="Acme renewal" --set customer-ref=00000000-0000-0000-0000-000000000000`,
739
+ raw: `{
740
+ "records": [
741
+ {
742
+ "deal-name": "Acme renewal",
743
+ "customer-ref": "00000000-0000-0000-0000-000000000000"
744
+ }
745
+ ]
746
+ }`,
747
+ response: `{
748
+ "created": [],
749
+ "errors": [
750
+ {
751
+ "index": 0,
752
+ "reason": "data_field_reference_not_found",
753
+ "message": "Referenced record was not found in the target schema.",
754
+ "action": "Use an existing record id or an existing display value for this reference field."
755
+ }
756
+ ]
732
757
  }`,
733
758
  },
734
759
  ]),
@@ -773,6 +798,24 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
773
798
  'zinkee --json records update contacts 550e8400-e29b-41d4-a716-446655440000 --unset contact-email --unset due-date',
774
799
  raw: `{
775
800
  "unset": ["contact-email", "due-date"]
801
+ }`,
802
+ },
803
+ {
804
+ description:
805
+ "Set a ReferenceField on an existing record. Pass the target record id (a bare UUID, or the compound 'recordId::anything' whose label is ignored) or an exact display value; the response shows the canonical 'recordId::displayValue' the server stored. If the reference doesn't exist the whole update is rejected with reason 'data_field_reference_not_found'.",
806
+ command:
807
+ 'zinkee --json records update deals 550e8400-e29b-41d4-a716-446655440000 --set customer-ref=8ad602a1-f6e3-43f6-9ab2-f1c5afc99621',
808
+ raw: `{
809
+ "set": {
810
+ "customer-ref": "8ad602a1-f6e3-43f6-9ab2-f1c5afc99621"
811
+ }
812
+ }`,
813
+ response: `{
814
+ "recordId": "550e8400-e29b-41d4-a716-446655440000",
815
+ "values": {
816
+ "deal-name": "Acme renewal",
817
+ "customer-ref": "8ad602a1-f6e3-43f6-9ab2-f1c5afc99621::Acme Corp"
818
+ }
776
819
  }`,
777
820
  },
778
821
  ]),