@openfn/language-common 1.13.3 → 1.13.5

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/dist/index.cjs CHANGED
@@ -111,6 +111,7 @@ var import_date_fns3 = __toESM(require("date-fns"), 1);
111
111
  var import_undici = require("undici");
112
112
  var import_http_status_codes = require("http-status-codes");
113
113
  var import_node_stream = require("stream");
114
+ var import_node_querystring = __toESM(require("querystring"), 1);
114
115
 
115
116
  // src/util/references.js
116
117
  var import_node_stream2 = require("stream");
package/dist/util.cjs CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
17
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
24
 
19
25
  // src/util/index.js
@@ -38,6 +44,7 @@ module.exports = __toCommonJS(util_exports);
38
44
  var import_undici = require("undici");
39
45
  var import_http_status_codes = require("http-status-codes");
40
46
  var import_node_stream = require("stream");
47
+ var import_node_querystring = __toESM(require("querystring"), 1);
41
48
  var clients = /* @__PURE__ */ new Map();
42
49
  var makeBasicAuthHeader = (username, password) => {
43
50
  const buff = Buffer.from(`${username}:${password}`);
@@ -67,6 +74,7 @@ var getClient = (baseUrl, options) => {
67
74
  };
68
75
  var enableMockClient = (baseUrl) => {
69
76
  const mockAgent = new import_undici.MockAgent({ connections: 1 });
77
+ mockAgent.disableNetConnect();
70
78
  const client = mockAgent.get(baseUrl);
71
79
  if (!clients.has(baseUrl)) {
72
80
  clients.set(baseUrl, client);
@@ -108,15 +116,21 @@ var parseUrl = (pathOrUrl = "", baseUrl) => {
108
116
  return {
109
117
  url: url.toString(),
110
118
  baseUrl: url.origin,
111
- path: url.pathname
119
+ path: url.pathname,
120
+ query: import_node_querystring.default.parse(url.searchParams.toString())
112
121
  };
113
122
  };
114
123
  async function request(method, fullUrlOrPath, options = {}) {
115
124
  const startTime = Date.now();
116
- const { url, baseUrl, path } = parseUrl(fullUrlOrPath, options.baseUrl);
125
+ const {
126
+ url,
127
+ baseUrl,
128
+ path,
129
+ query: urlQuery
130
+ } = parseUrl(fullUrlOrPath, options.baseUrl);
117
131
  const {
118
132
  headers = {},
119
- query = {},
133
+ query: optionQuery = {},
120
134
  body,
121
135
  errors = {},
122
136
  timeout = 3e5,
@@ -127,14 +141,18 @@ async function request(method, fullUrlOrPath, options = {}) {
127
141
  const client = getClient(baseUrl, { tls });
128
142
  const response = await client.request({
129
143
  path,
130
- query,
144
+ query: {
145
+ ...optionQuery,
146
+ ...urlQuery
147
+ },
131
148
  method,
132
149
  headers,
133
150
  body: encodeRequestBody(body),
134
151
  throwOnError: false,
135
152
  maxRedirections,
136
153
  bodyTimeout: timeout,
137
- headersTimeout: timeout
154
+ headersTimeout: timeout,
155
+ origin: baseUrl
138
156
  });
139
157
  const statusText = (0, import_http_status_codes.getReasonPhrase)(response.statusCode);
140
158
  await assertOK(response, errors, url, method, startTime);
package/dist/util.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Client, MockAgent } from "undici";
3
3
  import { getReasonPhrase } from "http-status-codes";
4
4
  import { Readable } from "stream";
5
+ import querystring from "querystring";
5
6
  var clients = /* @__PURE__ */ new Map();
6
7
  var makeBasicAuthHeader = (username, password) => {
7
8
  const buff = Buffer.from(`${username}:${password}`);
@@ -31,6 +32,7 @@ var getClient = (baseUrl, options) => {
31
32
  };
32
33
  var enableMockClient = (baseUrl) => {
33
34
  const mockAgent = new MockAgent({ connections: 1 });
35
+ mockAgent.disableNetConnect();
34
36
  const client = mockAgent.get(baseUrl);
35
37
  if (!clients.has(baseUrl)) {
36
38
  clients.set(baseUrl, client);
@@ -72,15 +74,21 @@ var parseUrl = (pathOrUrl = "", baseUrl) => {
72
74
  return {
73
75
  url: url.toString(),
74
76
  baseUrl: url.origin,
75
- path: url.pathname
77
+ path: url.pathname,
78
+ query: querystring.parse(url.searchParams.toString())
76
79
  };
77
80
  };
78
81
  async function request(method, fullUrlOrPath, options = {}) {
79
82
  const startTime = Date.now();
80
- const { url, baseUrl, path } = parseUrl(fullUrlOrPath, options.baseUrl);
83
+ const {
84
+ url,
85
+ baseUrl,
86
+ path,
87
+ query: urlQuery
88
+ } = parseUrl(fullUrlOrPath, options.baseUrl);
81
89
  const {
82
90
  headers = {},
83
- query = {},
91
+ query: optionQuery = {},
84
92
  body,
85
93
  errors = {},
86
94
  timeout = 3e5,
@@ -91,14 +99,18 @@ async function request(method, fullUrlOrPath, options = {}) {
91
99
  const client = getClient(baseUrl, { tls });
92
100
  const response = await client.request({
93
101
  path,
94
- query,
102
+ query: {
103
+ ...optionQuery,
104
+ ...urlQuery
105
+ },
95
106
  method,
96
107
  headers,
97
108
  body: encodeRequestBody(body),
98
109
  throwOnError: false,
99
110
  maxRedirections,
100
111
  bodyTimeout: timeout,
101
- headersTimeout: timeout
112
+ headersTimeout: timeout,
113
+ origin: baseUrl
102
114
  });
103
115
  const statusText = getReasonPhrase(response.statusCode);
104
116
  await assertOK(response, errors, url, method, startTime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-common",
3
- "version": "1.13.3",
3
+ "version": "1.13.5",
4
4
  "description": "Common Expressions for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -33,6 +33,7 @@ export function parseUrl(pathOrUrl: string, baseUrl: any): {
33
33
  url: string;
34
34
  baseUrl: string;
35
35
  path: string;
36
+ query: any;
36
37
  };
37
38
  export function get(url: any, options: any): Promise<{
38
39
  url: string;