@taruvi/sdk 1.4.5 → 1.4.6

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": "@taruvi/sdk",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Taruvi SDK",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -137,8 +137,9 @@ export class Database<T = Record<string, unknown>> {
137
137
  return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object, this.queryParams, { ...this.graphParams }, this.isEdges)
138
138
  }
139
139
 
140
- upsert(body: Partial<T> | Partial<T>[]): Database<T> {
141
- return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object, this.queryParams, { ...this.graphParams }, this.isEdges, true)
140
+ upsert(body: Partial<T> | Partial<T>[], uniqueFields?: string[]): Database<T> {
141
+ const qp = uniqueFields?.length ? { ...this.queryParams, unique_fields: uniqueFields.join(',') } : this.queryParams
142
+ return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object, qp, { ...this.graphParams }, this.isEdges, true)
142
143
  }
143
144
 
144
145
  update(body: Partial<T> | EdgeRequest): Database<T> {
@@ -16,7 +16,7 @@ export class Policy {
16
16
  const body = {
17
17
  resources: resources.map(r => ({
18
18
  resource: {
19
- kind: `${r.entityType}:${r.tableName}`,
19
+ kind: r.resource,
20
20
  id: r.recordId,
21
21
  attr: r.attributes || {}
22
22
  },
@@ -76,4 +76,4 @@ export class Policy {
76
76
 
77
77
  return []
78
78
  }
79
- }
79
+ }
@@ -13,8 +13,7 @@ export type Resource = {
13
13
  }
14
14
 
15
15
  export type Resources = {
16
- entityType: string
17
- tableName: string
16
+ resource: string
18
17
  recordId: string
19
18
  attributes: Record<string, unknown>
20
19
  actions: string[]
@@ -37,4 +36,4 @@ export type GetAllowedActionsOptions = {
37
36
  }
38
37
 
39
38
  // Response types - uses standard wrapper
40
- export type ResourceCheckResponse = TaruviResponse<PolicyCheckBatchResult>
39
+ export type ResourceCheckResponse = TaruviResponse<PolicyCheckBatchResult>
@@ -24,8 +24,7 @@ describe('Policy', () => {
24
24
  const policy = new Policy(mockClient)
25
25
  const result = await policy.checkResource([
26
26
  {
27
- entityType: 'crm',
28
- tableName: 'accounts',
27
+ resource: 'crm:accounts',
29
28
  recordId: 'record-123',
30
29
  attributes: { owner_id: 'user-456' },
31
30
  actions: ['read']
@@ -60,15 +59,13 @@ describe('Policy', () => {
60
59
  const policy = new Policy(mockClient)
61
60
  await policy.checkResource([
62
61
  {
63
- entityType: 'crm',
64
- tableName: 'accounts',
62
+ resource: 'crm:accounts',
65
63
  recordId: 'acc-1',
66
64
  attributes: {},
67
65
  actions: ['read', 'update']
68
66
  },
69
67
  {
70
- entityType: 'docs',
71
- tableName: 'documents',
68
+ resource: 'docs:documents',
72
69
  recordId: 'doc-1',
73
70
  attributes: {},
74
71
  actions: ['delete']
@@ -98,8 +95,7 @@ describe('Policy', () => {
98
95
  const policy = new Policy(mockClient)
99
96
  await policy.checkResource([
100
97
  {
101
- entityType: 'crm',
102
- tableName: 'contacts',
98
+ resource: 'crm:contacts',
103
99
  recordId: 'contact-1',
104
100
  attributes: {},
105
101
  actions: ['read']