@narrative.io/data-collaboration-sdk-ts 0.0.66 → 0.0.68

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.
@@ -6,6 +6,7 @@ export interface BaseAttribute {
6
6
  description?: string;
7
7
  type: string;
8
8
  validations?: string[];
9
+ metadata?: AttributeMetadata;
9
10
  }
10
11
  export interface PrimitiveAttribute extends BaseAttribute {
11
12
  type: 'string' | 'boolean' | 'double' | 'long' | 'timestamptz';
@@ -29,3 +30,13 @@ export interface ObjectAttribute extends BaseAttribute {
29
30
  properties: Record<string, SubAttribute | RefAttribute>;
30
31
  required?: string[];
31
32
  }
33
+ export interface AttributeMetadata {
34
+ attribute_cooccurrence: AttributeCooccurrence[];
35
+ }
36
+ export interface AttributeCooccurrence {
37
+ id: number;
38
+ name: string;
39
+ display_name?: string;
40
+ type?: string;
41
+ cooccurrence_pct: number;
42
+ }
@@ -41,7 +41,7 @@ async function getAttributesFromFields(fields) {
41
41
  attributesArray.push({
42
42
  attribute_id: attributeId,
43
43
  fields: fields.filter((field) => field.field.split('.')[0] === att),
44
- optional: fields.some(field => field.field.startsWith(att + '.') && field.filter !== undefined)
44
+ optional: fields.some(field => field.field.startsWith(att + '.') && field.filter === undefined)
45
45
  });
46
46
  });
47
47
  ensureAtLeastOneRequired(attributesArray);
@@ -65,10 +65,11 @@ async function getAttributesFromFields(fields) {
65
65
  * // The array is now guaranteed to have at least one object with `optional` set to `false`.
66
66
  */
67
67
  function ensureAtLeastOneRequired(dataRulesAttributes) {
68
- const hasMandatory = dataRulesAttributes.some(item => !item.optional);
68
+ const exportedAttributes = dataRulesAttributes.filter(item => item.fields.filter(field => field.exported).length > 0);
69
+ const hasMandatory = exportedAttributes.some(item => !item.optional);
69
70
  if (!hasMandatory) {
70
- const randomIndex = Math.floor(Math.random() * dataRulesAttributes.length);
71
- dataRulesAttributes[randomIndex].optional = false;
71
+ const randomIndex = Math.floor(Math.random() * exportedAttributes.length);
72
+ exportedAttributes[randomIndex].optional = false;
72
73
  }
73
74
  }
74
75
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrative.io/data-collaboration-sdk-ts",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "main": "build/index.js",
5
5
  "repository": "github:narrative-io/data-collaboration-sdk-ts",
6
6
  "source": "src/index.ts",