@openfn/language-odoo 1.0.0 → 1.0.1

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/ast.json CHANGED
@@ -17,7 +17,8 @@
17
17
  },
18
18
  {
19
19
  "title": "example",
20
- "description": "create(\"res.partner\", { name: \"Kool Keith\" }, {externalId: 23});"
20
+ "description": "create(\"res.partner\", { name: \"Kool Keith\" }, {externalId: 23});",
21
+ "caption": "Create a partner record with an external Id"
21
22
  },
22
23
  {
23
24
  "title": "function",
@@ -44,7 +45,7 @@
44
45
  },
45
46
  {
46
47
  "title": "param",
47
- "description": "Optional external ID for the record.",
48
+ "description": "Options to send to the request. Includes an optional external ID for the record.",
48
49
  "type": {
49
50
  "type": "NameExpression",
50
51
  "name": "object"
@@ -80,7 +81,7 @@
80
81
  },
81
82
  {
82
83
  "title": "example",
83
- "description": "read(\"res.partner\", [1] , [name]);",
84
+ "description": "read(\"res.partner\", [1] , ['name']);",
84
85
  "caption": "Download records with select fields"
85
86
  },
86
87
  {
@@ -113,10 +114,19 @@
113
114
  },
114
115
  {
115
116
  "title": "param",
116
- "description": "An optional array of fields to read from the record.",
117
- "type": {
118
- "type": "NameExpression",
119
- "name": "string"
117
+ "description": "An optional array of field strings to read from the record.",
118
+ "type": {
119
+ "type": "TypeApplication",
120
+ "expression": {
121
+ "type": "NameExpression",
122
+ "name": "Array"
123
+ },
124
+ "applications": [
125
+ {
126
+ "type": "NameExpression",
127
+ "name": "string"
128
+ }
129
+ ]
120
130
  },
121
131
  "name": "fields"
122
132
  },
package/dist/index.cjs CHANGED
@@ -100,7 +100,7 @@ async function login(state) {
100
100
  }
101
101
  return state;
102
102
  }
103
- function create(model, data, options) {
103
+ function create(model, data, options = {}) {
104
104
  return async (state) => {
105
105
  const [resolvedModel, resolvedData, resolvedOptions] = (0, import_util.expandReferences)(
106
106
  state,
@@ -108,11 +108,11 @@ function create(model, data, options) {
108
108
  data,
109
109
  options
110
110
  );
111
- console.log(resolvedModel, resolvedData, resolvedOptions);
111
+ console.log(`Creating a ${resolvedModel} resource...`);
112
112
  const response = await odooConn.create(
113
113
  resolvedModel,
114
114
  resolvedData,
115
- resolvedOptions.externalId
115
+ resolvedOptions == null ? void 0 : resolvedOptions.externalId
116
116
  );
117
117
  return (0, import_language_common.composeNextState)(state, response);
118
118
  };
@@ -125,7 +125,7 @@ function read(model, recordId, fields2 = []) {
125
125
  recordId,
126
126
  fields2
127
127
  );
128
- console.log(resolvedModel, resolvedRecordId, resolvedFields);
128
+ console.log(`Reading a ${resolvedModel} resource...`);
129
129
  const response = await odooConn.read(
130
130
  resolvedModel,
131
131
  resolvedRecordId,
@@ -142,7 +142,7 @@ function update(model, recordId, data) {
142
142
  recordId,
143
143
  data
144
144
  );
145
- console.log(resolvedModel, resolvedRecordId, resolvedData);
145
+ console.log(`Updating a ${resolvedModel} resource...`);
146
146
  const response = await odooConn.update(
147
147
  resolvedModel,
148
148
  resolvedRecordId,
@@ -158,7 +158,7 @@ function deleteRecord(model, recordId) {
158
158
  model,
159
159
  recordId
160
160
  );
161
- console.log(resolvedModel, resolvedRecordId);
161
+ console.log(`Deleting a ${resolvedModel} resource...`);
162
162
  const response = await odooConn.delete(resolvedModel, resolvedRecordId);
163
163
  return (0, import_language_common.composeNextState)(state, response);
164
164
  };
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ async function login(state) {
73
73
  }
74
74
  return state;
75
75
  }
76
- function create(model, data, options) {
76
+ function create(model, data, options = {}) {
77
77
  return async (state) => {
78
78
  const [resolvedModel, resolvedData, resolvedOptions] = expandReferences(
79
79
  state,
@@ -81,11 +81,11 @@ function create(model, data, options) {
81
81
  data,
82
82
  options
83
83
  );
84
- console.log(resolvedModel, resolvedData, resolvedOptions);
84
+ console.log(`Creating a ${resolvedModel} resource...`);
85
85
  const response = await odooConn.create(
86
86
  resolvedModel,
87
87
  resolvedData,
88
- resolvedOptions.externalId
88
+ resolvedOptions == null ? void 0 : resolvedOptions.externalId
89
89
  );
90
90
  return composeNextState(state, response);
91
91
  };
@@ -98,7 +98,7 @@ function read(model, recordId, fields2 = []) {
98
98
  recordId,
99
99
  fields2
100
100
  );
101
- console.log(resolvedModel, resolvedRecordId, resolvedFields);
101
+ console.log(`Reading a ${resolvedModel} resource...`);
102
102
  const response = await odooConn.read(
103
103
  resolvedModel,
104
104
  resolvedRecordId,
@@ -115,7 +115,7 @@ function update(model, recordId, data) {
115
115
  recordId,
116
116
  data
117
117
  );
118
- console.log(resolvedModel, resolvedRecordId, resolvedData);
118
+ console.log(`Updating a ${resolvedModel} resource...`);
119
119
  const response = await odooConn.update(
120
120
  resolvedModel,
121
121
  resolvedRecordId,
@@ -131,7 +131,7 @@ function deleteRecord(model, recordId) {
131
131
  model,
132
132
  recordId
133
133
  );
134
- console.log(resolvedModel, resolvedRecordId);
134
+ console.log(`Deleting a ${resolvedModel} resource...`);
135
135
  const response = await odooConn.delete(resolvedModel, resolvedRecordId);
136
136
  return composeNextState(state, response);
137
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-odoo",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "OpenFn odoo adaptor",
5
5
  "type": "module",
6
6
  "exports": {
@@ -15,29 +15,29 @@ export function setMockClient(mock: any): void;
15
15
  /**
16
16
  * Create a record in Odoo
17
17
  * @public
18
- * @example
18
+ * @example <caption> Create a partner record with an external Id</caption>
19
19
  * create("res.partner", { name: "Kool Keith" }, {externalId: 23});
20
20
  * @function
21
21
  * @param {string} model - The specific record model i.e. "res.partner"
22
22
  * @param {object} data - The data to be created in JSON.
23
- * @param {object} options - Optional external ID for the record.
23
+ * @param {object} options - Options to send to the request. Includes an optional external ID for the record.
24
24
  * @returns {Operation}
25
25
  */
26
- export function create(model: string, data: object, options: object): Operation;
26
+ export function create(model: string, data: object, options?: object): Operation;
27
27
  /**
28
28
  * Get a record from Odoo. Returns all fields unless a field list is provided as a third argument
29
29
  * @public
30
30
  * @example <caption>Download records with select fields</caption>
31
- * read("res.partner", [1] , [name]);
31
+ * read("res.partner", [1] , ['name']);
32
32
  * @example <caption>Download a single record with all fields</caption>
33
33
  * read("res.partner", $.recordIds);
34
34
  * @function
35
35
  * @param {string} model - The specific record model from i.e. "res.partner"
36
36
  * @param {number} recordId - An array of record IDs to read.
37
- * @param {string} fields - An optional array of fields to read from the record.
37
+ * @param {string[]} fields - An optional array of field strings to read from the record.
38
38
  * @returns {Operation}
39
39
  */
40
- export function read(model: string, recordId: number, fields?: string): Operation;
40
+ export function read(model: string, recordId: number, fields?: string[]): Operation;
41
41
  /**
42
42
  * Update a record in Odoo
43
43
  * @public