@atproto/common 0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # ATP Common Library
2
+
3
+ A library containing code which is shared between ATP packages.
@@ -0,0 +1 @@
1
+ module.exports = require('../../babel.config.js')
package/build.js ADDED
@@ -0,0 +1,22 @@
1
+ const pkgJson = require('@npmcli/package-json')
2
+ const { nodeExternalsPlugin } = require('esbuild-node-externals')
3
+
4
+ const buildShallow =
5
+ process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'
6
+
7
+ if (process.argv.includes('--update-main-to-dist')) {
8
+ return pkgJson
9
+ .load(__dirname)
10
+ .then((pkg) => pkg.update({ main: 'dist/index.js' }))
11
+ .then((pkg) => pkg.save())
12
+ }
13
+
14
+ require('esbuild').build({
15
+ logLevel: 'info',
16
+ entryPoints: ['src/index.ts'],
17
+ bundle: true,
18
+ sourcemap: true,
19
+ outdir: 'dist',
20
+ platform: 'node',
21
+ plugins: buildShallow ? [nodeExternalsPlugin()] : [],
22
+ })
@@ -0,0 +1,8 @@
1
+ import { CID } from 'multiformats/cid';
2
+ import * as Block from 'multiformats/block';
3
+ export declare const valueToIpldBlock: (data: unknown) => Promise<Block.Block<unknown>>;
4
+ export declare const sha256RawToCid: (hash: Uint8Array) => CID;
5
+ export declare const cidForData: (data: unknown) => Promise<CID>;
6
+ export declare const valueToIpldBytes: (value: unknown) => Uint8Array;
7
+ export declare const ipldBytesToValue: (bytes: Uint8Array) => unknown;
8
+ export declare const ipldBytesToRecord: (bytes: Uint8Array) => object;
@@ -0,0 +1,9 @@
1
+ export interface Def<T> {
2
+ parse: (obj: unknown) => T;
3
+ safeParse: (obj: unknown) => {
4
+ success: boolean;
5
+ };
6
+ }
7
+ export declare const is: <T>(obj: unknown, def: Def<T>) => obj is T;
8
+ export declare const assure: <T>(def: Def<T>, obj: unknown) => T;
9
+ export declare const isObject: (obj: unknown) => obj is Record<string, unknown>;
@@ -0,0 +1,8 @@
1
+ export * as check from './check';
2
+ export * as util from './util';
3
+ export * from './util';
4
+ export * from './tid';
5
+ export * from './blocks';
6
+ export * from './logger';
7
+ export * from './types';
8
+ export * from './streams';