@openfn/language-gmail 1.1.0 → 1.1.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
@@ -6,107 +6,56 @@
6
6
  "options"
7
7
  ],
8
8
  "docs": {
9
- "description": "Used to isolate the type of content to retrieve from the message.",
9
+ "description": "Downloads contents from messages of a Gmail account.",
10
10
  "tags": [
11
11
  {
12
- "title": "typedef",
12
+ "title": "public",
13
13
  "description": null,
14
- "type": {
15
- "type": "NameExpression",
16
- "name": "Object"
17
- },
18
- "name": "MessageContent"
14
+ "type": null
19
15
  },
20
16
  {
21
- "title": "public",
17
+ "title": "function",
22
18
  "description": null,
23
- "type": null
19
+ "name": null
24
20
  },
25
21
  {
26
- "title": "property",
27
- "description": "Message content type. Valid types: from, date, subject, body, archive, file.",
22
+ "title": "param",
23
+ "description": "Customized options including desired contents and query.",
28
24
  "type": {
29
- "type": "OptionalType",
30
- "expression": {
31
- "type": "NameExpression",
32
- "name": "string"
33
- }
25
+ "type": "NameExpression",
26
+ "name": "Options"
34
27
  },
35
- "name": "type"
28
+ "name": "options"
36
29
  },
37
30
  {
38
- "title": "property",
39
- "description": "A custom description for the content type.",
40
- "type": {
41
- "type": "OptionalType",
42
- "expression": {
43
- "type": "NameExpression",
44
- "name": "string"
45
- }
46
- },
47
- "name": "name"
48
- },
49
- {
50
- "title": "property",
51
- "description": "Identifier to isolate the desired attachment when type is 'archive'.\n Use a regular expression for pattern matching or a string for a literal match. Required if type is 'archive'.",
52
- "type": {
53
- "type": "OptionalType",
54
- "expression": {
55
- "type": "UnionType",
56
- "elements": [
57
- {
58
- "type": "NameExpression",
59
- "name": "RegExp"
60
- },
61
- {
62
- "type": "NameExpression",
63
- "name": "string"
64
- }
65
- ]
66
- }
67
- },
68
- "name": "archive"
69
- },
70
- {
71
- "title": "property",
72
- "description": "Identifier to isolate the desired attachment when type is 'file' or 'archive'.\n Use a regular expression for pattern matching or a string for a literal match. Required if type is 'file' or 'archive'.",
73
- "type": {
74
- "type": "OptionalType",
75
- "expression": {
76
- "type": "UnionType",
77
- "elements": [
78
- {
79
- "type": "NameExpression",
80
- "name": "RegExp"
81
- },
82
- {
83
- "type": "NameExpression",
84
- "name": "string"
85
- }
86
- ]
87
- }
88
- },
89
- "name": "file"
31
+ "title": "state",
32
+ "description": "{Array} data - The returned message objects, of the form `{ messageId, contents } `"
90
33
  },
91
34
  {
92
- "title": "property",
93
- "description": "Maximum number of characters to retrieve from the content.",
35
+ "title": "state",
36
+ "description": "{Array<string>} processedIds - An array of string ids processed by this request"
37
+ },
38
+ {
39
+ "title": "returns",
40
+ "description": null,
94
41
  "type": {
95
- "type": "OptionalType",
96
- "expression": {
97
- "type": "NullableType",
98
- "expression": {
99
- "type": "NameExpression",
100
- "name": "number"
101
- },
102
- "prefix": false
103
- }
104
- },
105
- "name": "maxLength"
42
+ "type": "NameExpression",
43
+ "name": "Operation"
44
+ }
45
+ },
46
+ {
47
+ "title": "example",
48
+ "description": "getContentsFromMessages(\n {\n query: 'subject:my+test+message'\n }\n)",
49
+ "caption": "Get a message with a specific subject"
50
+ },
51
+ {
52
+ "title": "example",
53
+ "description": "getContentsFromMessages(\n {\n query: 'after:15/01/2025',\n contents: [\n 'subject',\n { type: 'file', name: 'metadata', file: 'report.txt'}\n ]\n }\n)",
54
+ "caption": "Get messages after a specific date, with subject and report.txt attachment"
106
55
  }
107
56
  ]
108
57
  },
109
- "valid": false
58
+ "valid": true
110
59
  }
111
60
  ],
112
61
  "exports": [],
package/dist/index.cjs CHANGED
@@ -102,17 +102,11 @@ async function getMessageResult(userId, messageId) {
102
102
  headers: (_b = data == null ? void 0 : data.payload) == null ? void 0 : _b.headers
103
103
  };
104
104
  }
105
- function getContentIndicators(defaultContentRequests, contentRequests) {
106
- const indicators = /* @__PURE__ */ new Map();
107
- const requests = [
108
- ...defaultContentRequests || [],
109
- ...contentRequests || []
110
- ];
111
- for (const request of requests) {
112
- const indicator = getContentIndicator(request);
113
- indicators.set(indicator.type, indicator);
114
- }
115
- return Array.from(indicators.values());
105
+ function getContentIndicators(defaultContentRequests = [], contentRequests = []) {
106
+ const contentIndicators = contentRequests.map(getContentIndicator);
107
+ const contentNames = new Set(contentIndicators.map(({ name }) => name));
108
+ const defaultContentIndicators = defaultContentRequests.map(getContentIndicator).filter(({ name }) => !contentNames.has(name));
109
+ return [...defaultContentIndicators, ...contentIndicators];
116
110
  }
117
111
  function getContentIndicator(contentRequest) {
118
112
  const contentIndicator = typeof contentRequest === "string" ? { type: contentRequest } : { ...contentRequest };
package/dist/index.js CHANGED
@@ -67,17 +67,11 @@ async function getMessageResult(userId, messageId) {
67
67
  headers: (_b = data == null ? void 0 : data.payload) == null ? void 0 : _b.headers
68
68
  };
69
69
  }
70
- function getContentIndicators(defaultContentRequests, contentRequests) {
71
- const indicators = /* @__PURE__ */ new Map();
72
- const requests = [
73
- ...defaultContentRequests || [],
74
- ...contentRequests || []
75
- ];
76
- for (const request of requests) {
77
- const indicator = getContentIndicator(request);
78
- indicators.set(indicator.type, indicator);
79
- }
80
- return Array.from(indicators.values());
70
+ function getContentIndicators(defaultContentRequests = [], contentRequests = []) {
71
+ const contentIndicators = contentRequests.map(getContentIndicator);
72
+ const contentNames = new Set(contentIndicators.map(({ name }) => name));
73
+ const defaultContentIndicators = defaultContentRequests.map(getContentIndicator).filter(({ name }) => !contentNames.has(name));
74
+ return [...defaultContentIndicators, ...contentIndicators];
81
75
  }
82
76
  function getContentIndicator(contentRequest) {
83
77
  const contentIndicator = typeof contentRequest === "string" ? { type: contentRequest } : { ...contentRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-gmail",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "OpenFn gmail adaptor",
5
5
  "type": "module",
6
6
  "exports": {
package/types/Utils.d.ts CHANGED
@@ -8,7 +8,7 @@ export function getMessageResult(userId: any, messageId: any): Promise<{
8
8
  parts: any;
9
9
  headers: any;
10
10
  }>;
11
- export function getContentIndicators(defaultContentRequests: any, contentRequests: any): any[];
11
+ export function getContentIndicators(defaultContentRequests?: any[], contentRequests?: any[]): any[];
12
12
  export function getMessageContent(message: any, desiredContent: any): Promise<any>;
13
13
  export function createConnection(state: any): any;
14
14
  export function removeConnection(state: any): any;