Skip to content

v1.0.0-beta.5

Compare
Choose a tag to compare
@maslow maslow released this 22 Mar 18:05
· 764 commits to main since this release

What's Changed

  • fix(cli): fix axios config by @skyoct in #881
  • fix(web): fix MoreButton tooltip and npm package deletion confirm tip by @genie88 in #879
  • feat(cli): cli invoke function support parameters (#842) by @genie88 in #884
  • fix(cli): remove private npm mirror and replace AxiosRequestConfig to any by @skyoct in #886
  • feat(cli): init app support sync data by @skyoct in #895
  • feat(cli): rename name.meta.yaml to name.yaml by @skyoct in #893
  • fix(cli): fix publish package ignore file by @skyoct in #899
  • feat(web): add dark mode support (#891) by @genie88 in #900
  • fix(README): add chatGPT example by @zuoFeng59556 in #902
  • feat(subscription): impl subscription and account by @maslow in #894
  • feat(web): add subscription and wechat pay by @LeezQ in #904
  • feat(docs): add quick start todo by @zuoFeng59556 in #907
  • fix(server): add max renewal time in bundle; fix subscription price by @maslow in #908
  • doc: fix login example by @zuoFeng59556 in #911
  • chore(server): add sub field to find app api by @maslow in #913
  • refactor subscription dialog experience by @LeezQ in #914
  • fix(web): fix some dark mode ui bugs by @genie88 in #919
  • feat(cli): upgrade s3 sdk version by @skyoct in #922
  • refactor(web): upgrade icon by @LeezQ in #915
  • fix(server): fix bucket name regex by @maslow in #924
  • feat(server): add limit to update app state depends on subscription state by @maslow in #925
  • chore: remove contrib docs of laf web by @maslow in #927
  • feat(server): new authentication implements by @sulnong in #897
  • feat(web): impl new signup & signin method by @walle233 in #910
  • fix(server): change password signup phone filed to optional by @sulnong in #934
  • fix: web signup phone err by @walle233 in #935
  • fix: auth i18n english too long by @walle233 in #936
  • fix(server): fix init auth provider params by @maslow in #937
  • fix: sign up provider err by @walle233 in #938
  • doc: add cli README.md by @skyoct in #921
  • fix(server): deal with existed app without namespace by @maslow in #943
  • fix(web): update data use merge mode by @LeezQ in #940
  • fix(server): add regex for environment name by @maslow in #944
  • fix(server): stuck-starting instance blocked the task handler by @maslow in #945
  • doc: add function param and data query by @zuoFeng59556 in #948
  • refactor(web): updrage npm dependencies by @LeezQ in #950

New Contributors

Full Changelog: v1.0.0-beta.4...v1.0.0-beta.5

Migration points

Update Key Points

  • Add and adjust bundle fields
  • Subscription module
  • Account module
  • WeChat payment service
  • Improve multiple-region support

Breaks Changes

  1. Database: Bundle schema changes

    1. add limitCountPerUser field
    2. remove resource.limitCountPerUser field
    3. add subscriptionOptions field
    4. add resource.reservedTimeAfterExpired field
    5. add maxRenewalTime field
    6. remove specialPrice and price field
    • Operations

      db.Bundle.updateMany({}, {
      	$set: {
      		limitCountPerUser: 1,
      		maxRenewalTime: 3888000,
      		subscriptionOptions: [
      	    {
      	      "name": "monthly",
      	      "displayName": "1 Month",
      	      "duration": 2678400,
      	      "price": 0,
      	      "specialPrice": 0
      	    }
      		],
      		"resource.reservedTimeAfterExpired": 2678400
        }
      })
  2. Database: ApplicationBundle schema changes

    1. remove resource.limitCountPerUser field
    2. add resource.reservedTimeAfterExpired field
    3. add bundleId field
    • Operations

      db.ApplicationBundle.updateMany({}, {
      	$set: {
      		"resource.reservedTimeAfterExpired": 2678400,
          bundleId: new ObjectId("6405ffe6103ead6d468b1a17"),
      	}
      })
  3. Database: Region schema changes

    1. add storageConf.controlEndpoint field
    2. add databaseConf.controlConnectionUri field
  4. API: remove POST /v1/applications

    1. use POST /v1/subscriptions instead
  5. API: remove DELETE /v1/applications/:appid

    1. use DELETE v1/subscriptions instead
  6. Database: Add Subscriptions for existed applications

    1. expiredAt set to 1 month in future
    • Operations

      // write cloud function to insert subscriptions
      import cloud from '@lafjs/cloud'
      import { MongoClient, ObjectId, Db } from 'mongodb'
      
      const sys_db_uri = cloud.env.SYS_DB_URI
      // set your existed bundle id
      const bundleId = new ObjectId('6407200ca35fb4d684296d5c')
      
      export async function main(ctx: FunctionContext) {
        const client = new MongoClient(sys_db_uri)
        await client.connect()
      
        const db = client.db('sys_db')
      
        const apps = await db.collection('Application')
          .find()
          .toArray()
      
        for(let app of apps) {
          const res = await addSubscription(db, app, bundleId)
          console.log(app.appid, res)
        }
      
        return { data: 'hi, laf' }
      }
      
      async function addSubscription(db: Db, app: any, bundleId: ObjectId) {
        const sub = {
          "bundleId": bundleId,
          "appid": app.appid,
          "state": "Created",
          "phase": "Valid",
          "renewalPlan": "Manual",
          "expiredAt": new Date('2023-12-31T00:00:00.733Z'),
          "lockedAt": new Date('1970-01-01T00:00:00.000Z'),
          "createdAt": new Date(),
          "updatedAt": new Date(),
          "createdBy": app.createdBy,
          "input": {
            "name": app.name,
            "state": app.state,
            "regionId": app.regionId,
            "runtimeId": app.runtimeId
          }
        }
      
        return await db.collection('Subscription').insertOne(sub)
      }

New Configrations

Config phone auth provider

db.AuthProvider.updateOne({ name: "phone" }, {
	$set: {
           state: "Enabled",
          "config.alisms": {
	    "accessKeyId": "",
	    "accessKeySecret": "",
	    "api_entrypoint": "https://dysmsapi.aliyuncs.com",
	    "signName": "",
	    "templateCode": "SMS_000004"
	  }
      }
})

Add Wechat payment channel

// db.PaymentChannel.find().pretty()

db.PaymentChannel.insertOne({
  type: "WeChat",
  name: "WeChat Pay",
  spec: {
	  mchid: "",
           appid: "",
           apiV3Key: "",
           certificateSerialNumber: "",
          privateKey: "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----",
          publicKey: "----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"
  },
  state: "Active",
  createdAt: new Date(),
  updatedAt: new Date()
})