mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-05 13:02:54 +00:00
feat: migrate to esm
This commit is contained in:
2
examples/minimal-connector/app.js
Normal file
2
examples/minimal-connector/app.js
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import './lib/cli.js'
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "@openstapps/minimal-connector",
|
||||
"description": "This is a minimal connector which serves as an example",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
"repository": "git@gitlab.com:openstapps/minimal-connector.git",
|
||||
"author": "Anselm Stordeur <anselmstordeur@gmail.com>",
|
||||
@@ -48,8 +49,8 @@
|
||||
"nyc": "15.1.0",
|
||||
"rimraf": "4.4.0",
|
||||
"ts-node": "10.9.1",
|
||||
"typedoc": "0.22.18",
|
||||
"typescript": "4.4.4"
|
||||
"typedoc": "0.23.26",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018, 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -18,8 +16,8 @@ import {Logger} from '@openstapps/logger';
|
||||
import {Command} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
import {join} from 'path';
|
||||
import {executeConnector, isValidSCNamespace} from './common';
|
||||
import {MinimalConnector} from './minimal-connector';
|
||||
import {executeConnector, isValidSCNamespace} from './common.js';
|
||||
import {MinimalConnector} from './minimal-connector.js';
|
||||
|
||||
process.on('unhandledRejection', (error) => {
|
||||
throw error;
|
||||
@@ -34,7 +32,7 @@ const commander = new Command();
|
||||
|
||||
/**
|
||||
* Uses arguments to paramtrize the connector execution
|
||||
*
|
||||
*
|
||||
* backendURL - URL of the StApps backend deployment e.g. http://localhost:3000
|
||||
* origin - Origin, where the data comes from. Typically the name of the connector e.g. minimal-connector
|
||||
* licensePlate - The license plate of your school. Must be matched to a SCNamespace e.g. f-u
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ConnectorClient} from '@openstapps/api/lib/connector-client';
|
||||
import {HttpClient} from '@openstapps/api/lib/http-client';
|
||||
import {ConnectorClient} from '@openstapps/api/lib/connector-client.js';
|
||||
import {HttpClient} from '@openstapps/api/lib/http-client.js';
|
||||
import {
|
||||
SCLicensePlate,
|
||||
SCNamespaces,
|
||||
SCThings,
|
||||
} from '@openstapps/core';
|
||||
import {Connector} from './connector';
|
||||
import {Connector} from './connector.js';
|
||||
|
||||
/**
|
||||
* Checks if the input is a valid SCNamespace
|
||||
@@ -33,10 +33,10 @@ export function isValidSCNamespace(input: string): input is SCLicensePlate {
|
||||
|
||||
/**
|
||||
* Creates a uuid from a JSON stringified item identifier
|
||||
*
|
||||
*
|
||||
* You may create custom itemIdentifier-Interfaces to generate UIDs consistently
|
||||
*
|
||||
* @param itemIdentifier Identifying representation of the item
|
||||
* @param itemIdentifier Identifying representation of the item
|
||||
* @param licensePlate License plate of the school
|
||||
*/
|
||||
export function createUUID(itemIdentifier: unknown, licensePlate: SCLicensePlate): string {
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCLicensePlate, SCThingOriginType, SCThingRemoteOrigin, SCThings} from '@openstapps/core';
|
||||
import {createUUID} from './common';
|
||||
import {createUUID} from './common.js';
|
||||
|
||||
/**
|
||||
* Provides abstracted methods for the connector execution process
|
||||
*
|
||||
* Provides abstracted methods for the connector execution process
|
||||
*
|
||||
* By extending this class connector-developers only need to implement load and transform of the data
|
||||
* Pushing the data to the backend will be handled automatically
|
||||
*
|
||||
@@ -34,8 +34,8 @@ export abstract class Connector<T extends SCThings> {
|
||||
public origin: string;
|
||||
|
||||
/**
|
||||
* Abstract constructor for a connector
|
||||
*
|
||||
* Abstract constructor for a connector
|
||||
*
|
||||
* @param licensePlate License plate of the school
|
||||
* @param origin Name of the connector
|
||||
*/
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCLicensePlate, SCMessage, SCThingRemoteOrigin, SCThingType} from '@openstapps/core';
|
||||
import {createUUID} from './common';
|
||||
import {Connector} from './connector';
|
||||
import {createUUID} from './common.js';
|
||||
import {Connector} from './connector.js';
|
||||
|
||||
/**
|
||||
* Example connector
|
||||
@@ -27,7 +27,7 @@ export class MinimalConnector extends Connector<SCMessage> {
|
||||
|
||||
/**
|
||||
* Constructor for the MinimalConnector
|
||||
*
|
||||
*
|
||||
* @param licensePlate License plate of the school
|
||||
* @param origin Name of the connector
|
||||
*/
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
import {SCThingType, SCBulkResponse, SCLicensePlate} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from '@testdeck/mocha';
|
||||
import {MinimalConnector} from '../src/minimal-connector';
|
||||
import {createUUID, executeConnector, isValidSCNamespace} from '../src/common';
|
||||
import {MinimalConnector} from '../src/minimal-connector.js';
|
||||
import {createUUID, executeConnector, isValidSCNamespace} from '../src/common.js';
|
||||
import nock = require('nock');
|
||||
|
||||
@suite
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import {SCThingOriginType} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from '@testdeck/mocha';
|
||||
import {MinimalConnector} from '../src/minimal-connector';
|
||||
import {MinimalConnector} from '../src/minimal-connector.js';
|
||||
|
||||
@suite
|
||||
export class ConnectorSpec {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Validator} from '@openstapps/core-tools/lib/validate';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from '@testdeck/mocha';
|
||||
import {join} from 'path';
|
||||
import {MinimalConnector} from '../src/minimal-connector';
|
||||
import {MinimalConnector} from '../src/minimal-connector.js';
|
||||
|
||||
@suite
|
||||
export class MinimalConnectorSpec {
|
||||
|
||||
2
examples/minimal-plugin/app.js
Normal file
2
examples/minimal-plugin/app.js
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import './lib/cli.js'
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "@openstapps/minimal-plugin",
|
||||
"description": "Minimal Plugin",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
"author": "Thea Schöbl",
|
||||
"contributors": [
|
||||
@@ -36,7 +37,7 @@
|
||||
"@types/node": "18.15.3",
|
||||
"conventional-changelog-cli": "2.2.2",
|
||||
"rimraf": "4.4.0",
|
||||
"typedoc": "0.22.18",
|
||||
"typescript": "4.4.4"
|
||||
"typedoc": "0.23.26",
|
||||
"typescript": "4.8.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -15,14 +13,14 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {HttpClient} from '@openstapps/api/lib/http-client';
|
||||
import {PluginClient} from '@openstapps/api/lib/plugin-client';
|
||||
import {Converter} from '@openstapps/core-tools/lib/schema';
|
||||
import {HttpClient} from '@openstapps/api/lib/http-client.js';
|
||||
import {PluginClient} from '@openstapps/api/lib/plugin-client.js';
|
||||
import {Converter} from '@openstapps/core-tools/lib/schema.js';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Command, Option} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
import {join, resolve} from 'path';
|
||||
import {MinimalPlugin} from './plugin/minimal-plugin';
|
||||
import {MinimalPlugin} from './plugin/minimal-plugin.js';
|
||||
|
||||
|
||||
process.on('unhandledRejection', (error) => {
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Plugin} from '@openstapps/api/lib/plugin';
|
||||
import {Plugin} from '@openstapps/api/lib/plugin.js';
|
||||
import * as express from 'express';
|
||||
import {SCMinimalRequest} from './protocol/request';
|
||||
import {SCMinimalResponse} from './protocol/response';
|
||||
import {SCMinimalRequest} from './protocol/request.js';
|
||||
import {SCMinimalResponse} from './protocol/response.js';
|
||||
|
||||
/**
|
||||
* The Plugin Class
|
||||
|
||||
Reference in New Issue
Block a user