Skip to content

Commit

Permalink
More bundling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 23, 2022
1 parent 866a4fd commit 551f06c
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 917 deletions.
9 changes: 5 additions & 4 deletions lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

import { join } from 'node:path';

import { AbortController } from 'abort-controller';
import { Buffer } from 'buffer';
import { setTimeout } from 'isomorphic-timers-promises';
Expand All @@ -25,7 +23,7 @@ import type EventEmitter from 'eventemitter3';
import debug from 'debug';
import deepClone from 'deep-clone';
import { fileTypeFromBuffer } from 'file-type';
import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

import {
createNestedObject,
Expand Down Expand Up @@ -866,7 +864,10 @@ export class OADAClient {
// We could go to all the trouble of re-implementing tree puts for posts,
// but it's much easier to just make a ksuid and do the tree put
const newkey = ksuid();
return this.put({ ...request, path: join(path, newkey) });
return this.put({
...request,
path: (path.endsWith('/') ? path : `${path}/`) + newkey,
});
}

const contentType = await this.#guessContentType(request, pathArray);
Expand Down
2 changes: 1 addition & 1 deletion lib/event-iterator-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import type { on as onT, once as onceT } from 'events';

import { subscribe } from 'event-iterator/lib/dom';
import { subscribe } from 'event-iterator/lib/dom.js';

export async function* on(...[target, event, options]: Parameters<typeof onT>) {
yield* subscribe.call(target as unknown as EventTarget, event, options);
Expand Down
24 changes: 24 additions & 0 deletions lib/file-type-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2022 Open Ag Data Alliance
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { fileTypeFromBuffer as T } from 'file-type';

/**
* Shim this function to just return no result
*/
// eslint-disable-next-line unicorn/no-useless-undefined
export const fileTypeFromBuffer: typeof T = async () => undefined;
2 changes: 1 addition & 1 deletion lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import PQueue from 'p-queue';
import type { Response } from 'fetch-h2';
import debug from 'debug';
import { fromString } from 'media-type';
import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

import { assert as assertOADASocketRequest } from '@oada/types/oada/websockets/request.js';

Expand Down
14 changes: 0 additions & 14 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ declare module 'resolve-alpn' {
export = resolve;
}

/**
* Generates new (x)KSUID based on current timestamp
* @param {boolean} desc
* @param {number} timestamp ms
* @returns {string} 27 chars KSUID or 28 chars for xKSUID
*/
declare module 'xksuid' {
export function generate(desc = false, timestamp = Date.now()): string;
}

declare module 'xksuid/src/index.node.mjs' {
export * from 'xksuid';
}

declare module 'media-type' {
export interface MediaType {
type: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import PQueue from 'p-queue';
import ReconnectingWebSocket from 'reconnecting-websocket';
import WebSocket from 'isomorphic-ws';
import debug from 'debug';
import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';
import { setTimeout } from 'isomorphic-timers-promises';

import WebSocketRequest, {
Expand Down
24 changes: 8 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oada/client",
"version": "4.0.0",
"version": "4.0.1",
"description": "A lightweight client tool to interact with an OADA-compliant server",
"repository": "https://github.com/OADA/client",
"main": "dist/index.js",
Expand All @@ -13,15 +13,15 @@
"./dist/fetch.js": "cross-fetch",
"events": false,
"fetch-h2": false,
"path": "path-browserify",
"file-type": "./dist/file-type-browser.js",
"resolve-alpn": false
},
"react-native": {
"./dist/event-iterator.js": "./dist/event-iterator-browser.js",
"./dist/fetch.js": "cross-fetch",
"events": false,
"fetch-h2": false,
"path": "path-browserify",
"file-type": "./dist/file-type-browser.js",
"resolve-alpn": false
},
"files": [
Expand Down Expand Up @@ -87,28 +87,25 @@
"reconnecting-websocket": "^4.4.0",
"resolve-alpn": "^1.2.1",
"supports-color": "^9.2.2",
"tslib": "^2.3.1",
"tslib": "^2.4.0",
"utf-8-validate": "^5.0.9",
"ws": "^8.5.0",
"xksuid": "^0.0.2"
"xksuid": "https://github.com/qlever-llc/xksuid.git#commit=5b2761792b1b1b59ea71ab48df1252fcb851e502"
},
"devDependencies": {
"@ava/typescript": "^3.0.1",
"@tsconfig/node14": "^1.0.1",
"@types/debug": "^4.1.7",
"@types/events": "^3.0.0",
"@types/node": "^16.11.27",
"@types/type-is": "^1.6.3",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"@yarnpkg/sdks": "3.0.0-rc.2",
"ava": "4.0.0-rc.1",
"axios": "^0.26.1",
"c8": "^7.11.0",
"c8": "^7.11.2",
"dotenv": "^16.0.0",
"eslint": "^8.13.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-xo": "^0.40.0",
"eslint-config-xo-typescript": "^0.50.0",
Expand All @@ -133,13 +130,8 @@
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-sonarjs": "^0.13.0",
"eslint-plugin-unicorn": "^42.0.0",
"path-browserify": "^1.0.1",
"prettier": "^2.6.2",
"process": "^0.11.10",
"ts-loader": "^9.2.8",
"typescript": "4.6.3",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2"
"typescript": "4.6.3"
},
"packageManager": "yarn@3.2.0"
}
4 changes: 2 additions & 2 deletions test/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import { domain, token } from './config.js';

import test from 'ava';

import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

// eslint-disable-next-line import/no-namespace
import * as oada from '../dist/index.js';
import {
Nested,
deleteLinkAxios,
putAxios,
getAxios,
getTreeWithTestName,
putAxios,
putResourceAxios,
} from './utils.js';

Expand Down
2 changes: 1 addition & 1 deletion test/put.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { domain, token } from './config.js';

import test from 'ava';

import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

import {
Nested,
Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { domain, token } from './config.js';

import axios from 'axios';
import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

export type Nested =
| {
Expand Down
2 changes: 1 addition & 1 deletion test/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import test from 'ava';

import { EventEmitter, once } from 'node:events';

import { generate as ksuid } from 'xksuid/src/index.node.mjs';
import { generate as ksuid } from 'xksuid';

import { Change, OADAClient, connect } from '../dist/index.js';
import {
Expand Down
70 changes: 0 additions & 70 deletions webpack.config.js

This file was deleted.

Loading

0 comments on commit 551f06c

Please sign in to comment.