@absolutejs/commerce 0.0.1-beta.0

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/LICENSE ADDED
@@ -0,0 +1,83 @@
1
+ # Business Source License 1.1
2
+
3
+ **Licensor:** Alex Kahn
4
+
5
+ **Licensed Work:** @absolutejs/commerce (https://github.com/absolutejs/commerce)
6
+
7
+ **Change Date:** June 22, 2030
8
+
9
+ **Change License:** Apache License, Version 2.0
10
+
11
+ ---
12
+
13
+ ## Terms
14
+
15
+ The Licensor hereby grants you the right to copy, modify, create derivative
16
+ works, redistribute, and make non-production use of the Licensed Work. The
17
+ Licensor may make an Additional Use Grant, permitting limited production use.
18
+
19
+ ### Additional Use Grant
20
+
21
+ You may use the Licensed Work in production, provided your use does not include
22
+ any of the following:
23
+
24
+ 1. **Offering a Competing Service.** You may not offer the Licensed Work, or
25
+ any derivative or substantial portion of it, to third parties as a hosted or
26
+ managed service that competes with a hosted commerce, checkout, storefront,
27
+ or e-commerce backend platform (including, but not limited to, services like
28
+ Shopify, BigCommerce, Medusa Cloud, Commerce.js/Chec, Swell, or Saleor
29
+ Cloud). This includes any product whose primary value to its users is the
30
+ functionality the Licensed Work provides.
31
+
32
+ 2. **Resale or Redistribution as a Standalone Product.** You may not sell,
33
+ license, or distribute the Licensed Work, or any derivative or fork of it,
34
+ as a standalone commercial product.
35
+
36
+ 3. **Removal of Attribution.** Any derivative work, fork, or redistribution of
37
+ the Licensed Work must prominently credit AbsoluteJS and include a link to
38
+ the original project repository (https://github.com/absolutejs/commerce).
39
+
40
+ For clarity, the following uses are expressly permitted:
41
+
42
+ - Using the Licensed Work to build and operate your own stores, applications,
43
+ websites, internal tools, or SaaS products (whether commercial or
44
+ non-commercial), so long as the Licensed Work itself is not the primary
45
+ product you are selling.
46
+ - Using the Licensed Work as a dependency in commercial software you build and
47
+ sell, as long as the software is not itself a competing managed service of
48
+ the kind described in clause 1.
49
+ - Providing consulting, development, or professional services to clients using
50
+ the Licensed Work.
51
+ - Forking and modifying the Licensed Work for your own internal use, provided
52
+ attribution is maintained.
53
+
54
+ ### Change Date and Change License
55
+
56
+ On the Change Date specified above, or on such other date as the Licensor may
57
+ specify by written notice, the Licensed Work will be made available under the
58
+ Change License (Apache License, Version 2.0). Until the Change Date, the terms
59
+ of this Business Source License 1.1 apply.
60
+
61
+ ### Trademark
62
+
63
+ This license does not grant you any rights to use the "AbsoluteJS" or
64
+ "@absolutejs" name, logo, or any related trademarks. Forks and derivative works
65
+ must not be named or branded in a manner that suggests endorsement by or
66
+ affiliation with AbsoluteJS or the Licensor.
67
+
68
+ ### Notices
69
+
70
+ You must not remove or obscure any licensing, copyright, or other notices
71
+ included in the Licensed Work.
72
+
73
+ ### No Warranty
74
+
75
+ THE LICENSED WORK IS PROVIDED "AS IS". THE LICENSOR HEREBY DISCLAIMS ALL
76
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
77
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO
78
+ EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR
80
+ IN CONNECTION WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE
81
+ LICENSED WORK.
82
+
83
+ ---
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @absolutejs/commerce
2
+
3
+ Provider-agnostic commerce primitives for [AbsoluteJS](https://absolutejs.ai)
4
+ apps — so every shop isn't rebuilding cart, checkout, orders, and fulfillment
5
+ from scratch.
6
+
7
+ Follows the same shape as `@absolutejs/voice`: a host package holds the
8
+ **agnostic logic + adapter contracts**, and provider implementations live in
9
+ the [`commerce-adapters`](https://github.com/absolutejs/commerce-adapters)
10
+ monorepo (Apache-2.0).
11
+
12
+ ## v0 — shipping contract
13
+
14
+ The first slice is the carrier-agnostic shipping interface. Apps program against
15
+ `ShippingProvider`; a carrier adapter (e.g. `@absolutejs/commerce-easypost`)
16
+ implements it, so a shop can plug in whatever carrier account it already uses.
17
+
18
+ ```ts
19
+ import type { ShippingProvider } from '@absolutejs/commerce';
20
+ import { createEasyPostProvider } from '@absolutejs/commerce-easypost';
21
+
22
+ const shipping: ShippingProvider = createEasyPostProvider({
23
+ apiKey: process.env.EASYPOST_API_KEY!
24
+ });
25
+
26
+ const label = await shipping.buyCheapestLabel({ from, to, parcel });
27
+ // → { trackingNumber, labelUrl, carrier, service, amount, … }
28
+ ```
29
+
30
+ ## Roadmap
31
+
32
+ Being lifted from real AbsoluteJS shops next, against the same adapter pattern:
33
+
34
+ - Cart + pricing engine (variants, options, quantity breaks, setup fees)
35
+ - Order lifecycle + production-stage state machine
36
+ - `PaymentProvider` contract (Stripe adapter) + server-side re-pricing + webhook
37
+ fulfillment
38
+ - Discount-code engine
39
+ - B2B quotes → deposit → fulfill
40
+ - Branded transactional emails, proof-approval, `./drizzle` schema builders,
41
+ and a `./client` cart SDK
42
+
43
+ ## License
44
+
45
+ BSL-1.1 (converts to Apache-2.0 on the Change Date in `LICENSE`).
@@ -0,0 +1,71 @@
1
+ /** A postal address. `country` is an ISO-3166 alpha-2 code (e.g. "US"). */
2
+ export type Address = {
3
+ name: string;
4
+ company?: string | null;
5
+ street1: string;
6
+ street2?: string | null;
7
+ city: string;
8
+ state: string;
9
+ zip: string;
10
+ country: string;
11
+ phone?: string | null;
12
+ email?: string | null;
13
+ };
14
+ /** Parcel dimensions (inches) and weight (ounces). */
15
+ export type Parcel = {
16
+ lengthIn: number;
17
+ widthIn: number;
18
+ heightIn: number;
19
+ weightOz: number;
20
+ };
21
+ /** A purchasable rate quote from a carrier. */
22
+ export type ShippingRate = {
23
+ /** Adapter-specific id, used to buy this exact rate. */
24
+ id: string;
25
+ carrier: string;
26
+ service: string;
27
+ /** Price in the smallest currency unit's major form (e.g. dollars). */
28
+ amount: number;
29
+ currency: string;
30
+ estDeliveryDays: number | null;
31
+ };
32
+ /** A purchased label, ready to print, with its tracking handle. */
33
+ export type ShippingLabel = {
34
+ trackingNumber: string;
35
+ trackingUrl: string | null;
36
+ /** URL of the printable label (PDF/PNG). */
37
+ labelUrl: string;
38
+ carrier: string;
39
+ service: string;
40
+ amount: number;
41
+ currency: string;
42
+ rateId: string;
43
+ /** Adapter-specific shipment id (for follow-up calls). */
44
+ shipmentId: string;
45
+ };
46
+ export type RateInput = {
47
+ from: Address;
48
+ to: Address;
49
+ parcel: Parcel;
50
+ };
51
+ export type BuyInput = {
52
+ shipmentId: string;
53
+ rateId: string;
54
+ };
55
+ export type TrackResult = {
56
+ status: string;
57
+ estDelivery: string | null;
58
+ trackingUrl: string | null;
59
+ };
60
+ export type ShippingProvider = {
61
+ /** Quote all available rates for a parcel between two addresses. */
62
+ rates(input: RateInput): Promise<ShippingRate[]>;
63
+ /** Quote, pick the cheapest rate, and buy a label in one call. */
64
+ buyCheapestLabel(input: RateInput): Promise<ShippingLabel>;
65
+ /** Buy a specific previously-quoted rate. */
66
+ buyLabel(input: BuyInput): Promise<ShippingLabel>;
67
+ /** Current tracking status for a shipment. */
68
+ track(trackingNumber: string, carrier?: string): Promise<TrackResult>;
69
+ };
70
+ /** A sensible default parcel for small apparel orders (a poly mailer). */
71
+ export declare const DEFAULT_APPAREL_PARCEL: Parcel;
@@ -0,0 +1 @@
1
+ export * from './core/shipping';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ // src/core/shipping.ts
3
+ var DEFAULT_APPAREL_PARCEL = {
4
+ heightIn: 2,
5
+ lengthIn: 12,
6
+ weightOz: 8,
7
+ widthIn: 9
8
+ };
9
+ export {
10
+ DEFAULT_APPAREL_PARCEL
11
+ };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@absolutejs/commerce",
3
+ "version": "0.0.1-beta.0",
4
+ "description": "Provider-agnostic commerce primitives (cart, orders, fulfillment, shipping) for AbsoluteJS",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/absolutejs/commerce.git"
8
+ },
9
+ "homepage": "https://github.com/absolutejs/commerce",
10
+ "bugs": {
11
+ "url": "https://github.com/absolutejs/commerce/issues"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/index.js",
23
+ "types": "./dist/index.d.ts"
24
+ }
25
+ },
26
+ "license": "BSL-1.1",
27
+ "author": "Alex Kahn",
28
+ "scripts": {
29
+ "build": "rm -rf dist && bun build ./src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --project tsconfig.json",
30
+ "format": "prettier --write \"./**/*.{js,ts,json,md}\"",
31
+ "release": "bun run build && bun publish --tag beta",
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "devDependencies": {
35
+ "@types/bun": "1.3.9",
36
+ "typescript": "^5.9.3"
37
+ }
38
+ }